Mercurial > ift6266
changeset 118:0d083964af4b
small change to testtransformation to match with the pipeline behavior
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Wed, 17 Feb 2010 16:25:44 -0500 |
parents | c9d680d9a908 |
children | 4f37755d301b |
files | transformations/testtransformations.py |
diffstat | 1 files changed, 28 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/transformations/testtransformations.py Wed Feb 17 16:23:54 2010 -0500 +++ b/transformations/testtransformations.py Wed Feb 17 16:25:44 2010 -0500 @@ -31,17 +31,18 @@ MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(),GIMP1(),Rature(),Occlusion(), PermutPixel(),DistorsionGauss(),AddBackground(), PoivreSel(), BruitGauss(), Contrast()] ###---------------------complexity associated to each of them -complexity = [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5] +complexity = 0.6 #complexity = [0.5]*len(MODULE_INSTANCES) #complexity = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.] +n=100 def createimage(path,d): - for i in range(100): + for i in range(n): screen.fill(0) a=d[i,:] off1=4*32 off2=0 - for u in range(100): + for u in range(n): b=N.asarray(N.reshape(a,(32,32))) c=N.asarray([N.reshape(a*255.0,(32,32))]*3).T new=pygame.surfarray.make_surface(c) @@ -54,12 +55,15 @@ offset = 4*32 offset2 = 0 ct = 0 + ctmp = N.random.rand()*complexity + print u for j in MODULE_INSTANCES: #max dilation - ctmp = N.random.rand()*complexity[ct] - #random - print j.get_settings_names(), j.regenerate_parameters(ctmp) - + #ctmp = N.random.rand()*complexity[ct] + ctmp = N.random.rand()*complexity + #print j.get_settings_names(), j.regenerate_parameters(ctmp) + j.regenerate_parameters(ctmp) + b=j.transform_image(b) c=N.asarray([b*255]*3).T new=pygame.surfarray.make_surface(c) @@ -95,7 +99,7 @@ #pygame.display.init() screen = pygame.Surface((4*(nbmodule+1)/2*32,2*(4*32+20)),depth=32) -exemple = pygame.Surface((10*4*32,10*4*32),depth=32) +exemple = pygame.Surface((N.ceil(N.sqrt(n))*4*32,N.ceil(N.sqrt(n))*4*32),depth=32) anglcolorpalette=[(x,x,x) for x in xrange(0,256)] #pygame.Surface.set_palette(anglcolorpalette) @@ -103,19 +107,26 @@ pygame.font.init() -d = N.zeros((100,1024)) +d = N.zeros((n,1024)) + + +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) from Facade import * -for i in range(100): - d[i,:]=N.asarray(N.reshape(generateCaptcha(0,0),(1,1024))/255.0,dtype='float32') +for i in range(n): + d[i,:]=N.asarray(N.reshape(generateCaptcha(0.5,0),(1,1024))/255.0,dtype='float32') createimage('/u/glorotxa/transf/capcha',d) -for i in range(100): +for i in range(n): myttf2jpg = ttf2jpg() - d[i,:]=N.reshape(myttf2jpg.generate_image(),(1,1024)) + d[i,:]=N.reshape(myttf2jpg.generate_image()[0],(1,1024)) createimage('/u/glorotxa/transf/fonts',d) @@ -123,25 +134,18 @@ datapath = '/data/lisa/data/nist/by_class/' f = open(datapath+'lower/lower_train_data.ft') d = ft.read(f) -d = d[0:100,:]/255.0 +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:100,:]/255.0 +d = d[0:n,:]/255.0 createimage('/u/glorotxa/transf/NIST_upper',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:100,:]/255.0 -createimage('/u/glorotxa/transf/NIST_digits',d) - -datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft/' +datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft' f = open(datapath) d = ft.read(f) -d = d[0:100,:]/255.0 +d = d[0:n,:]/255.0 createimage('/u/glorotxa/transf/OCR',d)