comparison transformations/testtransformations.py @ 129:a507adba0ce3

Changes to fit with visualisation
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Thu, 18 Feb 2010 14:43:53 -0500
parents 5e00ed18ae32
children
comparison
equal deleted inserted replaced
125:5d3a7a4e30e9 129:a507adba0ce3
60 for j in MODULE_INSTANCES: 60 for j in MODULE_INSTANCES:
61 #max dilation 61 #max dilation
62 #ctmp = N.random.rand()*complexity[ct] 62 #ctmp = N.random.rand()*complexity[ct]
63 ctmp = N.random.rand()*complexity 63 ctmp = N.random.rand()*complexity
64 #print j.get_settings_names(), j.regenerate_parameters(ctmp) 64 #print j.get_settings_names(), j.regenerate_parameters(ctmp)
65 j.regenerate_parameters(ctmp) 65 th=j.regenerate_parameters(ctmp)
66 66
67 b=j.transform_image(b) 67 b=j.transform_image(b)
68 c=N.asarray([b*255]*3).T 68 c=N.asarray([b*255]*3).T
69 new=pygame.surfarray.make_surface(c) 69 new=pygame.surfarray.make_surface(c)
70 new=pygame.transform.scale2x(new) 70 new=pygame.transform.scale2x(new)
72 if u==0: 72 if u==0:
73 #new.set_palette(anglcolorpalette) 73 #new.set_palette(anglcolorpalette)
74 screen.blit(new,(offset,offset2)) 74 screen.blit(new,(offset,offset2))
75 font = pygame.font.SysFont('liberationserif',18) 75 font = pygame.font.SysFont('liberationserif',18)
76 text = font.render('%s '%(int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0)) 76 text = font.render('%s '%(int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0))
77 #if j.__module__ == 'Rature':
78 # text = font.render('%s,%s'%(th[-1],int(ctmp*100.0)/100.0) + j.__module__,0,(255,255,255),(0,0,0))
77 screen.blit(text,(offset,offset2+4*32)) 79 screen.blit(text,(offset,offset2+4*32))
78 if ct == len(MODULE_INSTANCES)/2-1: 80 if ct == len(MODULE_INSTANCES)/2-1:
79 offset = 0 81 offset = 0
80 offset2 = 4*32+20 82 offset2 = 4*32+20
81 else: 83 else:
107 109
108 pygame.font.init() 110 pygame.font.init()
109 111
110 d = N.zeros((n,1024)) 112 d = N.zeros((n,1024))
111 113
114 datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft'
115 f = open(datapath)
116 d = ft.read(f)
117 d = d[0:n,:]/255.0
118 createimage('/u/glorotxa/transf/OCR',d)
119
120
121
122 datapath = '/data/lisa/data/nist/by_class/'
123 f = open(datapath+'digits_reshuffled/digits_reshuffled_train_data.ft')
124 d = ft.read(f)
125 d = d[0:n,:]/255.0
126 createimage('/u/glorotxa/transf/NIST_digits',d)
127
128
129
130 datapath = '/data/lisa/data/nist/by_class/'
131 f = open(datapath+'upper/upper_train_data.ft')
132 d = ft.read(f)
133 d = d[0:n,:]/255.0
134 createimage('/u/glorotxa/transf/NIST_upper',d)
135
112 from Facade import * 136 from Facade import *
113 137
114 for i in range(n): 138 for i in range(n):
115 d[i,:]=N.asarray(N.reshape(generateCaptcha(0.8,0),(1,1024))/255.0,dtype='float32') 139 d[i,:]=N.asarray(N.reshape(generateCaptcha(0.8,0),(1,1024))/255.0,dtype='float32')
116 140
120 for i in range(n): 144 for i in range(n):
121 myttf2jpg = ttf2jpg() 145 myttf2jpg = ttf2jpg()
122 d[i,:]=N.reshape(myttf2jpg.generate_image()[0],(1,1024)) 146 d[i,:]=N.reshape(myttf2jpg.generate_image()[0],(1,1024))
123 createimage('/u/glorotxa/transf/fonts',d) 147 createimage('/u/glorotxa/transf/fonts',d)
124 148
125
126 datapath = '/data/lisa/data/nist/by_class/'
127 f = open(datapath+'digits_reshuffled/digits_reshuffled_train_data.ft')
128 d = ft.read(f)
129 d = d[0:n,:]/255.0
130 createimage('/u/glorotxa/transf/NIST_digits',d)
131
132
133 datapath = '/data/lisa/data/nist/by_class/' 149 datapath = '/data/lisa/data/nist/by_class/'
134 f = open(datapath+'lower/lower_train_data.ft') 150 f = open(datapath+'lower/lower_train_data.ft')
135 d = ft.read(f) 151 d = ft.read(f)
136 d = d[0:n,:]/255.0 152 d = d[0:n,:]/255.0
137 createimage('/u/glorotxa/transf/NIST_lower',d) 153 createimage('/u/glorotxa/transf/NIST_lower',d)
138 154
139 datapath = '/data/lisa/data/nist/by_class/'
140 f = open(datapath+'upper/upper_train_data.ft')
141 d = ft.read(f)
142 d = d[0:n,:]/255.0
143 createimage('/u/glorotxa/transf/NIST_upper',d)
144 datapath = '/data/lisa/data/ocr_breuel/filetensor/unlv-corrected-2010-02-01-shuffled.ft'
145 f = open(datapath)
146 d = ft.read(f)
147 d = d[0:n,:]/255.0
148 createimage('/u/glorotxa/transf/OCR',d)
149
150
151
152
153 155
154 #pygame.display.quit() 156 #pygame.display.quit()