MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / generate

Function generate

test_generation.py:442–482  ·  view source on GitHub ↗
(model, opt)

Source from the content-addressed store, hash-verified

440
441
442def generate(model, opt):
443
444 _, test_dataset = get_dataset(opt.dataroot, opt.npoints, opt.category)
445
446 test_dataloader = torch.utils.data.DataLoader(test_dataset, batch_size=opt.batch_size,
447 shuffle=False, num_workers=int(opt.workers), drop_last=False)
448
449 with torch.no_grad():
450
451 samples = []
452 ref = []
453
454 for i, data in tqdm(enumerate(test_dataloader), total=len(test_dataloader), desc='Generating Samples'):
455
456 x = data['test_points'].transpose(1,2)
457 m, s = data['mean'].float(), data['std'].float()
458
459 gen = model.gen_samples(x.shape,
460 'cuda', clip_denoised=False).detach().cpu()
461
462 gen = gen.transpose(1,2).contiguous()
463 x = x.transpose(1,2).contiguous()
464
465
466
467 gen = gen * s + m
468 x = x * s + m
469 samples.append(gen)
470 ref.append(x)
471
472 visualize_pointcloud_batch(os.path.join(str(Path(opt.eval_path).parent), 'x.png'), gen[:64], None,
473 None, None)
474
475 samples = torch.cat(samples, dim=0)
476 ref = torch.cat(ref, dim=0)
477
478 torch.save(samples, opt.eval_path)
479
480
481
482 return ref
483
484
485def main(opt):

Callers 1

mainFunction · 0.85

Calls 3

get_datasetFunction · 0.70
gen_samplesMethod · 0.45

Tested by

no test coverage detected