Python options.test_options.TestOptions() Examples

The following are 5 code examples of options.test_options.TestOptions(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module options.test_options , or try the search function .
Example #1
Source File: test.py    From SingleGAN with MIT License 6 votes vote down vote up
def main():    
    opt = TestOptions().parse()
    opt.no_flip = True  
    opt.batchSize = 1

    data_loader = CreateDataLoader(opt)

    model = SingleGAN()
    model.initialize(opt)

    web_dir = os.path.join(opt.results_dir, 'test')
    webpage = html.HTML(web_dir, 'task {}'.format(opt.name))

    for i, data in enumerate(islice(data_loader, opt.how_many)):
        print('process input image %3.3d/%3.3d' % (i, opt.how_many))
        all_images, all_names = model.translation(data)
        img_path = 'image%3.3i' % i
        save_images(webpage, all_images, all_names, img_path, None, width=opt.fineSize)
            
    webpage.save() 
Example #2
Source File: test.py    From MeshCNN with MIT License 5 votes vote down vote up
def run_test(epoch=-1):
    print('Running Test')
    opt = TestOptions().parse()
    opt.serial_batches = True  # no shuffle
    dataset = DataLoader(opt)
    model = create_model(opt)
    writer = Writer(opt)
    # test
    writer.reset_counter()
    for i, data in enumerate(dataset):
        model.set_input(data)
        ncorrect, nexamples = model.test()
        writer.update_counter(ncorrect, nexamples)
    writer.print_acc(epoch, writer.acc)
    return writer.acc 
Example #3
Source File: test.py    From DMIT with MIT License 5 votes vote down vote up
def main():    
    opt = TestOptions().parse()
    opt.is_flip = False  
    opt.batchSize = 1
    data_loader = CreateDataLoader(opt)
    model = create_model(opt) 
    web_dir = os.path.join(opt.results_dir, 'test')
    webpage = html.HTML(web_dir, 'task {}'.format(opt.exp_name))

    for i, data in enumerate(islice(data_loader, opt.how_many)):
        print('process input image %3.3d/%3.3d' % (i, opt.how_many))
        results = model.translation(data)
        img_path = 'image%3.3i' % i
        save_images(webpage, results, img_path, None, width=opt.fine_size)
    webpage.save() 
Example #4
Source File: test.py    From GANimation with GNU General Public License v3.0 5 votes vote down vote up
def main():
    opt = TestOptions().parse()
    if not os.path.isdir(opt.output_dir):
        os.makedirs(opt.output_dir)

    morph = MorphFacesInTheWild(opt)

    image_path = opt.input_path
    expression = np.random.uniform(0, 1, opt.cond_nc)
    morph.morph_file(image_path, expression) 
Example #5
Source File: ocrd_anybaseocr_dewarp.py    From ocrd_anybaseocr with Apache License 2.0 5 votes vote down vote up
def prepare_options(self, path):
        sys.path.append(path)
        from options.test_options import TestOptions
        from models.models import create_model
        sys.argv = [sys.argv[0]]
        os.mkdir(self.input_file_grp+"/test_A/")
        opt = TestOptions().parse(save=False)
        opt.nThreads = 1   # test code only supports nThreads = 1
        opt.batchSize = 1  # test code only supports batchSize = 1
        opt.serial_batches = True  # no shuffle
        opt.no_flip = True  # no flip
        opt.rood_dir = self.input_file_grp # make into proper path
        opt.checkpoints_dir = self.parameter['checkpoint_dir'] 
        opt.dataroot = self.input_file_grp
        opt.name = self.parameter['model_name']
        opt.label_nc = 0
        opt.no_instance = True
        opt.resize_or_crop = self.parameter['imgresize']
        opt.n_blocks_global = 10
        opt.n_local_enhancers = 2
        opt.gpu_ids = [self.parameter['gpu_id']]
        opt.loadSize = self.parameter['resizeHeight']
        opt.fineSize = self.parameter['resizeWidth']
        
        model = create_model(opt)
    
        return opt, model