Esempio n. 1
0
    def save(self):
        # if self.
        if not self.isInit:
            save_dir = QtGui.QFileDialog.getExistingDirectory(
                None, 'Select a folder to save the result', self.default_dir,
                QtGui.QFileDialog.ShowDirsOnly)
            self.isInit = True
            self.save_dir = str(save_dir)
            utils.mkdirs(self.save_dir)
            self.html = image_save.ImageSave(self.save_dir,
                                             'Gui screenshot',
                                             append=True)

        print('save the result to (%s)' % self.save_dir)

        if self.z is not None:
            self.z_dir = os.path.join(self.save_dir, 'z_vectors')
            utils.mkdirs(self.z_dir)
            utils.PickleSave(
                os.path.join(
                    self.z_dir, 'z_drawing%3.3d_%3.3d' %
                    (self.reset_count, self.save_count)), self.z)

        if self.ims is not None:
            txts = [''] * self.ims.shape[0]
            self.html.save_image(
                self.ims,
                txts=txts,
                header='generated images (Drawing %3.3d, Step %3.3d)' %
                (self.reset_count, self.save_count),
                cvt=True,
                width=128)
            self.html.save()
            self.save_count += 1
Esempio n. 2
0
npx, n_layers, n_f, nc, nz, niter, niter_decay = getattr(
    train_dcgan_config, args.model_name)()
expr_name = args.model_name + args.ext

if not args.cache_dir:
    args.cache_dir = './cache/%s/' % expr_name

for arg in vars(args):
    print('[%s] =' % arg, getattr(args, arg))

# create directories
rec_dir = os.path.join(args.cache_dir, 'rec')
model_dir = os.path.join(args.cache_dir, 'models')
log_dir = os.path.join(args.cache_dir, 'log')
web_dir = os.path.join(args.cache_dir, 'web_rec')
html = image_save.ImageSave(web_dir, expr_name, append=True)
utils.mkdirs([rec_dir, model_dir, log_dir, web_dir])

# load data
tr_data, te_data, tr_stream, te_stream, ntrain, ntest \
    = load_imgs(ntrain=None, ntest=None, batch_size=args.batch_size, data_file=args.data_file)
te_handle = te_data.open()
ntest = int(np.floor(ntest / float(args.batch_size)) * args.batch_size)
# st()
test_x, = te_data.get_data(te_handle, slice(0, ntest))

test_x = train_dcgan_utils.transform(test_x, nc=nc)
predict_params = train_dcgan_utils.init_predict_params(nz=nz,
                                                       n_f=n_f,
                                                       n_layers=n_layers,
                                                       nc=nc)