Mercurial > ift6266
annotate data_generation/pipeline/testtransformations.py @ 195:92c9a6c48ce9
Add option for test.py to test modules specified on the command-line.
author | Arnaud Bergeron <abergeron@gmail.com> |
---|---|
date | Tue, 02 Mar 2010 18:01:22 -0500 |
parents | 5e0e5f1860ec |
children | 0de14b2034c6 |
rev | line source |
---|---|
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
2 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
3 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
4 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
5 from pylearn.io import filetensor as ft |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
6 import copy |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
7 import pygame |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
8 import time |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
9 import numpy as N |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
10 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
11 from ttf2jpg import ttf2jpg |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
12 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
13 #from gimpfu import * |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
14 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
15 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
16 from PoivreSel import PoivreSel |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
17 from thick import Thick |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
18 from BruitGauss import BruitGauss |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
19 from DistorsionGauss import DistorsionGauss |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
20 from PermutPixel import PermutPixel |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
21 from gimp_script import GIMP1 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
22 from Rature import Rature |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
23 from contrast import Contrast |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
24 from local_elastic_distortions import LocalElasticDistorter |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
25 from slant import Slant |
80
4407ab3f7805
small display change in testtransformation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
57
diff
changeset
|
26 from Occlusion import Occlusion |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
27 from add_background_image import AddBackground |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
28 from affine_transform import AffineTransformation |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
29 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
30 ###---------------------order of transformation module |
97
b3d15100842a
Changed order of transformation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
94
diff
changeset
|
31 MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(),GIMP1(),Rature(),Occlusion(), PermutPixel(),DistorsionGauss(),AddBackground(), PoivreSel(), BruitGauss(), Contrast()] |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
32 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
33 ###---------------------complexity associated to each of them |
120
5e00ed18ae32
changed some transformation paramters to better fit with visualization
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
118
diff
changeset
|
34 complexity = 0.7 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
35 #complexity = [0.5]*len(MODULE_INSTANCES) |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
36 #complexity = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.] |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
37 n=100 |
80
4407ab3f7805
small display change in testtransformation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
57
diff
changeset
|
38 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
39 def createimage(path,d): |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
40 for i in range(n): |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
41 screen.fill(0) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
42 a=d[i,:] |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
43 off1=4*32 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
44 off2=0 |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
45 for u in range(n): |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
46 b=N.asarray(N.reshape(a,(32,32))) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
47 c=N.asarray([N.reshape(a*255.0,(32,32))]*3).T |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
48 new=pygame.surfarray.make_surface(c) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
49 new=pygame.transform.scale2x(new) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
50 new=pygame.transform.scale2x(new) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
51 #new.set_palette(anglcolorpalette) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
52 screen.blit(new,(0,0)) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
53 exemple.blit(new,(0,0)) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
54 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
55 offset = 4*32 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
56 offset2 = 0 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
57 ct = 0 |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
58 ctmp = N.random.rand()*complexity |
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
59 print u |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
60 for j in MODULE_INSTANCES: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
61 #max dilation |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
62 #ctmp = N.random.rand()*complexity[ct] |
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
63 ctmp = N.random.rand()*complexity |
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
64 #print j.get_settings_names(), j.regenerate_parameters(ctmp) |
129
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
65 th=j.regenerate_parameters(ctmp) |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
66 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
67 b=j.transform_image(b) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
68 c=N.asarray([b*255]*3).T |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
69 new=pygame.surfarray.make_surface(c) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
70 new=pygame.transform.scale2x(new) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
71 new=pygame.transform.scale2x(new) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
72 if u==0: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
73 #new.set_palette(anglcolorpalette) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
74 screen.blit(new,(offset,offset2)) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
75 font = pygame.font.SysFont('liberationserif',18) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
76 text = font.render('%s '%(int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0)) |
129
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
77 #if j.__module__ == 'Rature': |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
78 # text = font.render('%s,%s'%(th[-1],int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0)) |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
79 screen.blit(text,(offset,offset2+4*32)) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
80 if ct == len(MODULE_INSTANCES)/2-1: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
81 offset = 0 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
82 offset2 = 4*32+20 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
83 else: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
84 offset += 4*32 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
85 ct+=1 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
86 exemple.blit(new,(off1,off2)) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
87 if off1 != 9*4*32: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
88 off1+=4*32 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
89 else: |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
90 off1=0 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
91 off2+=4*32 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
92 pygame.image.save(exemple,path+'/perimages/%s.PNG'%i) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
93 pygame.image.save(screen,path+'/exemples/%s.PNG'%i) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
94 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
95 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
96 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
97 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
98 nbmodule = len(MODULE_INSTANCES) |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
99 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
100 pygame.surfarray.use_arraytype('numpy') |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
101 |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
102 #pygame.display.init() |
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
103 screen = pygame.Surface((4*(nbmodule+1)/2*32,2*(4*32+20)),depth=32) |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
104 exemple = pygame.Surface((N.ceil(N.sqrt(n))*4*32,N.ceil(N.sqrt(n))*4*32),depth=32) |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
105 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
106 anglcolorpalette=[(x,x,x) for x in xrange(0,256)] |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
107 #pygame.Surface.set_palette(anglcolorpalette) |
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
108 #screen.set_palette(anglcolorpalette) |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
109 |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
110 pygame.font.init() |
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
111 |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
112 d = N.zeros((n,1024)) |
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
113 |
129
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
114 datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft' |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
115 f = open(datapath) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
116 d = ft.read(f) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
117 d = d[0:n,:]/255.0 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
118 createimage('/u/glorotxa/transf/OCR',d) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
119 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
120 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
121 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
122 datapath = '/data/lisa/data/nist/by_class/' |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
123 f = open(datapath+'digits_reshuffled/digits_reshuffled_train_data.ft') |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
124 d = ft.read(f) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
125 d = d[0:n,:]/255.0 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
126 createimage('/u/glorotxa/transf/NIST_digits',d) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
127 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
128 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
129 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
130 datapath = '/data/lisa/data/nist/by_class/' |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
131 f = open(datapath+'upper/upper_train_data.ft') |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
132 d = ft.read(f) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
133 d = d[0:n,:]/255.0 |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
134 createimage('/u/glorotxa/transf/NIST_upper',d) |
a507adba0ce3
Changes to fit with visualisation
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
120
diff
changeset
|
135 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
136 from Facade import * |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
137 |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
138 for i in range(n): |
120
5e00ed18ae32
changed some transformation paramters to better fit with visualization
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
118
diff
changeset
|
139 d[i,:]=N.asarray(N.reshape(generateCaptcha(0.8,0),(1,1024))/255.0,dtype='float32') |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
140 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
141 createimage('/u/glorotxa/transf/capcha',d) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
142 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
143 |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
144 for i in range(n): |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
145 myttf2jpg = ttf2jpg() |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
146 d[i,:]=N.reshape(myttf2jpg.generate_image()[0],(1,1024)) |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
147 createimage('/u/glorotxa/transf/fonts',d) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
148 |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
149 datapath = '/data/lisa/data/nist/by_class/' |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
150 f = open(datapath+'lower/lower_train_data.ft') |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
151 d = ft.read(f) |
118
0d083964af4b
small change to testtransformation to match with the pipeline behavior
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
113
diff
changeset
|
152 d = d[0:n,:]/255.0 |
113
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
153 createimage('/u/glorotxa/transf/NIST_lower',d) |
291d749452df
testtransformation.py to source from all the available data
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
97
diff
changeset
|
154 |
57
6846136b2201
Add a simple test script to see transformation step by step
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
diff
changeset
|
155 |
84
104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
Xavier Glorot <glorotxa@iro.umontreal.ca>
parents:
80
diff
changeset
|
156 #pygame.display.quit() |