This repository has been archived by the owner on Jan 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
139 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class DescriptorGenerator: | ||
|
||
@staticmethod | ||
def generate_origin_descriptor(): | ||
return 0 | ||
|
||
@staticmethod | ||
def generate_descriptor(data): | ||
return 0 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+5 Bytes
(100%)
Projet/EdgeDetection/__pycache__/EdgeDetection.cpython-35.pyc
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from Bootstrap import Bootstrap | ||
|
||
boot = Bootstrap() | ||
boot.run() | ||
Bootstrap().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from EdgeDetection.EdgeDetection import EdgeDetection | ||
from Clipping.Clipping import Clipping | ||
from BoundaryTracing.BoudaryTracing import BoundaryTracing | ||
|
||
from Shared.Borg import Borg | ||
|
||
class Pipeline(Borg): | ||
def __init__(self): | ||
self.edgeDetec = EdgeDetection() | ||
self.clip = Clipping() | ||
self.boundTrac = BoundaryTracing() | ||
|
||
def run(self, input): | ||
edges_image = self.edgeDetec.detect_edges(input) | ||
clipped_image = self.clip.clip(edges_image) | ||
|
||
return clipped_image |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Borg: | ||
_shared_state = {} | ||
def __init__(self): | ||
self.__dict__ = self._shared_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Parameters: | ||
parameters = {} | ||
|
||
@staticmethod | ||
def set_parameters(new_parameters): | ||
Parameters.parameters.update(new_parameters) | ||
|
||
@staticmethod | ||
def get_parameters(): | ||
return Parameters.parameters |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from PIL import Image | ||
from os import listdir | ||
import numpy as np | ||
|
||
from Utils.ReadWrite import ReadWrite | ||
from Classifier.DescriptorGenerator import DescriptorGenerator | ||
from Pipeline.Pipeline import Pipeline | ||
|
||
from Shared.Borg import Borg | ||
from Shared.Parameters import Parameters | ||
|
||
class Trainer(Borg): | ||
def __init__(self): | ||
p = Parameters.get_parameters() | ||
self.path_data = p['training_set'] | ||
self.path_model = p['model_path'] | ||
|
||
def train(self): | ||
actu_letter = None | ||
|
||
training_data_files = listdir(self.path_data) | ||
print(training_data_files) | ||
|
||
centroid_actu_descriptor = DescriptorGenerator.generate_origin_descriptor() | ||
|
||
count = 0 | ||
|
||
for i in range(0, len(training_data_files)): | ||
if training_data_files[i].split('_') == actu_letter: | ||
count = count + 1 | ||
|
||
img = np.asarray(Image.open(self.path_data + training_data_files[i]).convert('L')) | ||
data = Pipeline().run(img) | ||
|
||
centroid_actu_descriptor = centroid_actu_descriptor + DescriptorGenerator.generate_descriptor(data) | ||
|
||
else: | ||
centroid_actu_descriptor = centroid_actu_descriptor / count | ||
ReadWrite.write(self.path_model, actu_letter + ' ' + centroid_actu_descriptor) | ||
|
||
actu_letter = training_data_files[i].split('_') | ||
centroid_actu_descriptor = DescriptorGenerator.generate_origin_descriptor() | ||
count = 0 | ||
|
||
|
File renamed without changes.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class ReadWrite: | ||
@staticmethod | ||
def read(path): | ||
file = open(path, 'r') | ||
return file.readlines() | ||
|
||
@staticmethod | ||
def write(path, data): | ||
file = open(path, 'a+') | ||
file.write(data) | ||
file.close() | ||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.