Mercurial > ift6266
changeset 129:a507adba0ce3
Changes to fit with visualisation
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Thu, 18 Feb 2010 14:43:53 -0500 |
parents | 5d3a7a4e30e9 |
children | 38929c29b602 |
files | transformations/Occlusion.py transformations/Rature.py transformations/testtransformations.py |
diffstat | 3 files changed, 37 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/transformations/Occlusion.py Thu Feb 18 12:58:34 2010 -0500 +++ b/transformations/Occlusion.py Thu Feb 18 14:43:53 2010 -0500 @@ -76,7 +76,7 @@ self.y_arrivee=int(numpy.random.normal(0,3)) self.rajout=numpy.random.randint(0,self.longueur-1) #les bouts de quelle lettre - self.appliquer=numpy.random.binomial(1,0.4) ##### 30 % du temps, on met une occlusion ##### + self.appliquer=numpy.random.binomial(1,0.4) ##### 40 % du temps, on met une occlusion ##### if complexity == 0: #On ne fait rien dans ce cas self.applique=0
--- a/transformations/Rature.py Thu Feb 18 12:58:34 2010 -0500 +++ b/transformations/Rature.py Thu Feb 18 14:43:53 2010 -0500 @@ -67,7 +67,7 @@ self.angle=int(numpy.random.normal(90,100*complexity)) - self.faire=numpy.random.binomial(1,0.2) ##### 15% d'effectuer une rature ##### + self.faire=numpy.random.binomial(1,0.15) ##### 15% d'effectuer une rature ##### if next_rature: self.faire = 1 #self.faire=1 #Pour tester seulement @@ -82,7 +82,15 @@ self.smooth=4 else: self.smooth=3 - self.nb_ratures=1+int(numpy.random.rand()*3) + + p = numpy.random.rand() + if p < 0.5: + self.nb_ratures= 1 + else: + if p < 0.8: + self.nb_ratures = 2 + else: + self.nb_ratures = 3 #Creation de la "patch" de rature qui sera appliquee sur l'image if self.faire == 1: @@ -110,10 +118,7 @@ self.get_patch(crop) def get_patch(self,crop): - - - smooting=numpy.zeros((self.smooth,self.smooth))+1 #Au plus c'est gros, au plus ca rapetisse la ligne - + smooting = numpy.ones((self.smooth,self.smooth)) #Il y a deux erosions afin d'avoir un beau resultat. Pas trop large et #pas trop mince trans=scipy.ndimage.morphology.grey_erosion\
--- a/transformations/testtransformations.py Thu Feb 18 12:58:34 2010 -0500 +++ b/transformations/testtransformations.py Thu Feb 18 14:43:53 2010 -0500 @@ -62,7 +62,7 @@ #ctmp = N.random.rand()*complexity[ct] ctmp = N.random.rand()*complexity #print j.get_settings_names(), j.regenerate_parameters(ctmp) - j.regenerate_parameters(ctmp) + th=j.regenerate_parameters(ctmp) b=j.transform_image(b) c=N.asarray([b*255]*3).T @@ -74,6 +74,8 @@ screen.blit(new,(offset,offset2)) font = pygame.font.SysFont('liberationserif',18) text = font.render('%s '%(int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0)) + #if j.__module__ == 'Rature': + # text = font.render('%s,%s'%(th[-1],int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0)) screen.blit(text,(offset,offset2+4*32)) if ct == len(MODULE_INSTANCES)/2-1: offset = 0 @@ -109,6 +111,28 @@ d = N.zeros((n,1024)) +datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft' +f = open(datapath) +d = ft.read(f) +d = d[0:n,:]/255.0 +createimage('/u/glorotxa/transf/OCR',d) + + + +datapath = '/data/lisa/data/nist/by_class/' +f = open(datapath+'digits_reshuffled/digits_reshuffled_train_data.ft') +d = ft.read(f) +d = d[0:n,:]/255.0 +createimage('/u/glorotxa/transf/NIST_digits',d) + + + +datapath = '/data/lisa/data/nist/by_class/' +f = open(datapath+'upper/upper_train_data.ft') +d = ft.read(f) +d = d[0:n,:]/255.0 +createimage('/u/glorotxa/transf/NIST_upper',d) + from Facade import * for i in range(n): @@ -122,33 +146,11 @@ d[i,:]=N.reshape(myttf2jpg.generate_image()[0],(1,1024)) createimage('/u/glorotxa/transf/fonts',d) - -datapath = '/data/lisa/data/nist/by_class/' -f = open(datapath+'digits_reshuffled/digits_reshuffled_train_data.ft') -d = ft.read(f) -d = d[0:n,:]/255.0 -createimage('/u/glorotxa/transf/NIST_digits',d) - - datapath = '/data/lisa/data/nist/by_class/' f = open(datapath+'lower/lower_train_data.ft') d = ft.read(f) d = d[0:n,:]/255.0 createimage('/u/glorotxa/transf/NIST_lower',d) -datapath = '/data/lisa/data/nist/by_class/' -f = open(datapath+'upper/upper_train_data.ft') -d = ft.read(f) -d = d[0:n,:]/255.0 -createimage('/u/glorotxa/transf/NIST_upper',d) -datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft' -f = open(datapath) -d = ft.read(f) -d = d[0:n,:]/255.0 -createimage('/u/glorotxa/transf/OCR',d) - - - - #pygame.display.quit()