def prepare_data(self,idxs=None): if self.dataset is 'kth': print 'loading from KTH dataset' x_train0, x_test0, y_train0, y_test0 = \ get_kth_imgs(N=50000,n=self.n,reCalc=False,resize=self.original_dim) x_train0[0],_ = synth2(224,H=0.3) x_train0[1],_ = synth2(224,H=0.5) for i in range(2): x_train0[i]-=np.min(x_train0[i]*1.0) x_train0[i]=x_train0[i]/np.max(x_train0[i])*256.0 print 'two first samples are fBm' elif self.dataset is 'other': # fbm print 'loading from OTHER (fbm) dataset' x_train0, x_test0, y_train0, y_test0 = \ get_other_imgs(N=1000,n=self.n,reCalc=False,resize=self.original_dim) #print 'NOT IMPLEMENTED' elif self.dataset is 'kurtsim': print 'loading from kurt (sim) dataset' x_train0, x_test0, y_train0, y_test0 = \ get_kurtsim_imgs(N=120,n=self.n,reCalc=False,resize=self.original_dim) else: print 'NOT IMPLEMENTED' if self.dataset is 'kth' and idxs is not None: return x_train0[idxs], x_test0, y_train0[idxs], y_test0 else: return x_train0, x_test0, y_train0, y_test0
def get_G_kth(): texture = Texture() original_dim = 224**2 n=200 x_train0, x_test0, y_train0, y_test0 = \ get_kth_imgs(N=50000,n=n,reCalc=False,resize=original_dim) saved_G = '/home/ido/disk/KTH_G.bin' saved_F = '/home/ido/disk/KTH_F.bin' gg = [] ff = [] x_train0 = x_train0 x_train0[0],_ = synth2(224,H=0.3) x_train0[1],_ = synth2(224,H=0.5) for i in range(2): x_train0[i]-=np.min(x_train0[i]*1.0) x_train0[i]=x_train0[i]/np.max(x_train0[i])*256.0 print 'two first samples are fBm' #plt.imshow(x_train0[0]) for i,im in enumerate(x_train0): print i, '/', len(x_train0) im = np.stack([im,im,im],axis=2).astype(np.float32) # grayscale G0, F0 = texture.synTexture(im,onlyGram = True) gg.append(G0) ff.append(F0) pickle.dump(gg,open(saved_G,'w')) pickle.dump(ff,open(saved_F,'w'))
def prepare_data(self,idxs=None): x_train0, x_test0, y_train0, y_test0 = \ get_kth_imgs(N=50000,n=self.n,reCalc=False,resize=self.original_dim) x_train0[0],_ = synth2(224,H=0.3) x_train0[1],_ = synth2(224,H=0.5) for i in range(2): x_train0[i]-=np.min(x_train0[i]*1.0) x_train0[i]=x_train0[i]/np.max(x_train0[i])*256.0 print 'two first samples are fBm' if idxs is not None: return x_train0[idxs], x_test0, y_train0[idxs], y_test0 else: return x_train0, x_test0, y_train0, y_test0
# train the VAE on MNIST digits original_dim = 32 * 32 # 784 original_dim2 = int(np.sqrt(original_dim)) (x_train0, y_train0), (x_test0, y_test0) = mnist.load_data() n = 32 use_fbms = False batch_size = 100 if use_fbms: print('USING fBms') x_train0, x_test0, y_train0, y_test0 = \ generate_2d_fbms(N=50000,n=n,reCalc=False,resize=original_dim) else: print('using real imgs') x_train0, x_test0, y_train0, y_test0 = \ get_kth_imgs(N=50000,n=n,reCalc=False,resize=original_dim) localphase = LocalPhase(x_train0, x_test0, y_train0, y_test0, recalc_stats=True) y_test0 = localphase.agg_y_test y_train0 = localphase.agg_y_train maxlen = (len(x_train0) / batch_size) * batch_size x_train0 = x_train0[:maxlen] y_train0 = y_train0[:maxlen] maxlen = (len(x_test0) / batch_size) * batch_size x_test0 = x_test0[:maxlen] y_test0 = y_test0[:maxlen] ############################################################