Exemplo n.º 1
0
 def __init__(self, opt: options.Options, device: D):
     super(MeshGen, self).__init__(opt, device)
     self.generator.eval()
     template_name, template = load_template_mesh(opt, opt.start_level)
     self.template = MeshInference(template_name, template, self.opt,
                                   self.opt.start_level).to(self.device)
     self.reconstruction_z = factory.NoiseMem(opt).load().to(device)
Exemplo n.º 2
0
                    f'gen {self.opt.mesh_name} {i * num_samples + j +1:02d} / {len(self.generator.levels) * num_samples}'
                )

    def __call__(self, start_level: int):
        with torch.no_grad():
            if start_level < 0:
                start_level = len(self)
            start_level = min(len(self), start_level)
            z = self.compose_z(start_level)
            return self.generator(self.template.copy(), z, len(self) - 1)


if __name__ == '__main__':
    opt_ = options.Options()
    opt_.parse_cmdline()
    device = CPU
    with_noise = False
    if opt_.gen_mode == 'generate':
        mg = MeshGen(opt_, device)
        mg.generate_all(opt_.num_gen_samples)
    elif opt_.gen_mode == 'animate':
        m2m = Mesh2Mesh(opt_, device)
        in_mesh = MeshInference(
            opt_.target, mesh_utils.load_real_mesh(opt_.target, 0, True), opt_,
            0).to(device)
        m2m.animate(in_mesh,
                    opt_.gen_levels[0],
                    opt_.gen_levels[1],
                    0, (12, 17),
                    zero_places=(0, 0, 1, 1, 1))