示例#1
0
 def on_epoch_end(self, iternum, GAN, logs={}):
     out = io.BytesIO()
     val = None
     if self.title == 'genimg':
         plots.save_img_grid(GAN.genrtor,
                             GAN.noise_vect_len,
                             fname=out,
                             Xterm=False,
                             scale=GAN.cscale)
     elif self.title == 'pixhist':
         val = plots.pix_intensity_hist(GAN.val_imgs,
                                        GAN.genrtor,
                                        GAN.noise_vect_len,
                                        scaling=GAN.datascale,
                                        fname=out,
                                        Xterm=False)
     out.seek(0)
     image = _filebuf_to_tf_summary_img(out, self.title)
     summary = tf.Summary(
         value=[tf.Summary.Value(tag=self.title, image=image)])
     writer = tf.summary.FileWriter(GAN.expDir + 'logs/imgs')
     writer.add_summary(summary, iternum)
     writer.close()
     out.close()
     return val
示例#2
0
GAN.genrtor.load_weights(modelpath)

# Plot generated images
plots.save_img_grid(GAN.genrtor,
                    GAN.noise_vect_len,
                    GAN.invtransform,
                    GAN.C_axis,
                    Xterm=True,
                    scale=GAN.cscale,
                    multichannel=GAN.multichannel)

# Plot pixel intensity histogram and calculate chi-square score
chi = plots.pix_intensity_hist(GAN.val_imgs,
                               GAN.genrtor,
                               GAN.noise_vect_len,
                               GAN.invtransform,
                               GAN.C_axis,
                               multichannel=GAN.multichannel,
                               Xterm=True)

# Plot power spectrum and calculate chi-square score
pschi = plots.pspect(GAN.val_imgs,
                     GAN.genrtor,
                     GAN.invtransform,
                     GAN.noise_vect_len,
                     GAN.C_axis,
                     Xterm=True,
                     multichannel=GAN.multichannel)

plt.show()
示例#3
0
#stacked = Model(z, decision)
#stacked.compile(loss=lossfn, optimizer=keras.optimizers.Adam(lr=0.0002, beta_1=0.5))

noise_vects1 = np.random.normal(loc=0.0, size=(10, 1, noise_vect_len))

reals = real_imgs[:10, :, :, :]
fakes = genrtor.predict(noise_vects1)

#plots.save_realimg_grid(real_imgs, Xterm=True, scale='lin')
#plots.save_img_grid(genrtor, noise_vect_len, 0, Xterm=True, scale='pwr')
plots.save_img_grid(genrtor, noise_vect_len, 0, Xterm=True, scale='pwr')
plots.save_img_grid(genrtor, noise_vect_len, 0, Xterm=True, scale='pwr')
#wdw = [-1.1, 1.1, 1e-4, 3e4]
chi = plots.pix_intensity_hist(real_imgs,
                               genrtor,
                               noise_vect_len,
                               'lin',
                               Xterm=True)
plt.show()
print('Chi=%f' % chi)

#noise_vects1 = np.random.normal(loc=0.0, size=(127000, 1, noise_vect_len))
#fakes = genrtor.predict(noise_vects1)
#np.save('./data/gen/fullcrop.npy', fakes)
'''
print(discrim.predict(reals))
print(discrim.predict(fakes))
print(stacked.predict(noise_vects1))

batchsize = 64
real_batch = real_imgs[27:27+batchsize,:,:,:]