Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Commit

Permalink
final push
Browse files Browse the repository at this point in the history
  • Loading branch information
LeC-D committed Nov 30, 2018
1 parent afbb6d5 commit c318a78
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Projet/Bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import re
from PIL import Image

from Utils.ArgParser import ArgParser
Expand Down Expand Up @@ -41,7 +42,9 @@ def run(self):

for i in descs:
nw_letter = i[0]
nw_desc = [str(j) for j in range(1, len(i))]
nw_desc = [float(j) for j in re.findall(r"[\d.]+", i)]
print(desc_i)
print(nw_desc)
dist_actu = DescriptorGenerator.distance(desc_i, nw_desc)
if dist_actu < min_diff:
min_diff = dist_actu
Expand Down
2 changes: 1 addition & 1 deletion Projet/BoundaryTracing/BoudaryTracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def trace(self):
if self.UD != old_ud and self.UD == -1:
count_up = 0

if br == 1200:
if br == 2000:
print('hello')
break
# test = np.asarray(self.image)
Expand Down
Binary file modified Projet/BoundaryTracing/__pycache__/BoudaryTracing.cpython-35.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion Projet/Classifier/DescriptorGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def generate_descriptor(data):

for i in range(0, len(new_xs)):
new_element = f(new_xs[i])
print(new_element)
new_ys.append(complex(new_element[0], new_element[1]))

new_ys = np.absolute(np.array(new_ys)).tolist()
Expand Down
Binary file modified Projet/Classifier/__pycache__/DescriptorGenerator.cpython-35.pyc
Binary file not shown.
4 changes: 0 additions & 4 deletions Projet/Pipeline/Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ def __init__(self):
def run(self, input):
edges_image = self.edgeDetec.detect_edges(input)
clipped_image = self.clip.clip(edges_image)
'''test = np.asarray(clipped_image)
t = Image.fromarray(test)
plot = plt.imshow(t)
plt.show()'''
bound_image_data = self.boundTrac.run(clipped_image)
return bound_image_data
Binary file modified Projet/Pipeline/__pycache__/Pipeline.cpython-35.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions Projet/TrainedModel/model.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
w1.0 0.9870267806503344 0.9735362460720288 0.9592011029025258 0.9444022989991473 0.9297016926464909 0.9151825506371228 0.9006585487464958 0.886078303648402 0.8716498276384175 0.8572174514383347 0.8427728456855207 0.8283871042253792 0.8139705129568293 0.7997401909060731 0.7854649036910545 0.7713265261892785 0.7571625616602837 0.7431998005953263 0.7293491527161432 3.0
u1.0 0.990458439758131 0.9809945324129336 0.9715460351773836 0.9620734074294379 0.9526160991975022 0.9432082954380068 0.9337661627924588 0.9243103782572862 0.9148578948608076 0.9053949760523091 0.8959455305382876 0.8865070039223456 0.8771391752180615 0.8677121618699647 0.8582783900101427 0.8488472646547812 0.8394453664053069 0.8300278380951315 0.8206303887905347 2.6666666666666665
i1.0 0.9900330805393018 0.9799267684402521 0.969930105294399 0.959881692786049 0.9499156444225191 0.9398973109387505 0.9299774093264649 0.9200253729792116 0.9100629703796151 0.9001260117635439 0.8901920518403313 0.8801535582036658 0.8700370433409732 0.86009749990915 0.850073645335427 0.8399486477413898 0.8298637313668864 0.8198221593662403 0.8097006638519503 1.2
k1.0 0.9890627882870118 0.9782829326972156 0.9674863521904538 0.956866694995331 0.9461545671250953 0.9355640241069237 0.9249872258319893 0.9144955222106349 0.9039873220128651 0.8934687466801673 0.8829877804977714 0.8725835462755951 0.8622110014706869 0.851791511046461 0.8414312611982354 0.8311457952825035 0.8209161550728566 0.8107271068871501 0.8005378277464835 2.6666666666666665
v1.0 0.9908625429770358 0.9812518791129468 0.9712776041163959 0.9608201778717635 0.9504642891241538 0.9400845283761637 0.9296254565969266 0.9192627027758454 0.9089493279242049 0.8988023964646481 0.8885606365705078 0.8783739810800189 0.8682272127224749 0.8580528867725095 0.8479810197435752 0.8378830644394221 0.8278841577993532 0.8177546513048264 0.8077600172155925 3.3333333333333335
l1.0 0.9886313261973856 0.9772047725728248 0.9657746123152318 0.9544108668081015 0.9430958457951536 0.9317388494016104 0.920402854335435 0.9089975231231584 0.8976785449994307 0.8864096334358293 0.8750702218313482 0.8637831231836044 0.8525010664051405 0.8412772553760819 0.8300644250778888 0.8188846300851933 0.8077280304571433 0.7966288375514582 0.7854463833800481 5.0
f1.0 0.9909766928148457 0.981913793867278 0.9729159200132932 0.9639032400225703 0.9548842260070639 0.9458745952659744 0.9368670203501704 0.9278850208101751 0.918888478304557 0.9099011066950535 0.9009319996927229 0.8919469882340932 0.8829966311604174 0.8740314694311492 0.8650507613342873 0.8560921775643651 0.8471387147037911 0.8381668533120411 0.8292185503444749 2.0
b1.0 0.9907304352236308 0.9810954099217086 0.9714609406327653 0.9619155900916428 0.9523781397271012 0.9428540324598401 0.9332770587485351 0.9237059365225558 0.9142210614543377 0.9046273708905108 0.8950912494060923 0.8855549966533088 0.8760235850325813 0.8665141183845557 0.8569448773155468 0.8474593414751496 0.8379623097120816 0.8284928692949312 0.8190007298770767 2.8
8 changes: 6 additions & 2 deletions Projet/Training/Trainer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from PIL import Image
from os import listdir, walk
from operator import add
import numpy as np

from Utils.ReadWrite import ReadWrite
Expand All @@ -26,14 +27,17 @@ def train(self):
if not(actu_letter in descs):
descs[actu_letter] = [DescriptorGenerator.generate_origin_descriptor(), 0]


img = np.asarray(Image.open(self.path_data + training_data_files[i]).convert('L'))
data = Pipeline().run(img)
nw_desc = DescriptorGenerator.generate_descriptor(data)

descs[actu_letter] = np.array(descs[actu_letter]) + np.array([nw_desc, 1])
print(descs[actu_letter])

descs[actu_letter] = [list(map(add, descs[actu_letter][0], nw_desc)), descs[actu_letter][1] + 1]

for key in descs:
data_to_add = np.array(descs[key][0]) / descs[key][1]
ReadWrite.write(self.path_model, key + " ".join(str(x) for x in data_to_add.list()))
ReadWrite.write(self.path_model, key + " ".join(str(x) for x in data_to_add.tolist()))


Binary file modified Projet/Training/__pycache__/Trainer.cpython-35.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion Projet/Utils/ReadWrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def read(path):
@staticmethod
def write(path, data):
file = open(path, 'a+')
file.write(data)
file.write(data + '\n')
file.close()


Binary file modified Projet/Utils/__pycache__/ReadWrite.cpython-35.pyc
Binary file not shown.
Binary file modified Projet/__pycache__/Bootstrap.cpython-35.pyc
Binary file not shown.

0 comments on commit c318a78

Please sign in to comment.