IGLICT / SketchFaceNeRF

Apache License 2.0
102 stars 12 forks source link

If it’s a NERF how does one export the .json file and images together #6

Open BlockchainPunks opened 11 months ago

BlockchainPunks commented 11 months ago

Can you confirm it’s a NRF being generated and how to get the .json file to support the images

ty625911724 commented 7 months ago

Sorry for late reply.

The generated results are NeRF faces. It currenly do not export .json file. You could change the pitch and yaw to generate faces in different poses.

DongChengdongHangZhou commented 6 months ago

Use my code to generate the face observed from different angles!

in inference_handdraw.py

-------------save pSp img----------------

    cam_pivot = torch.tensor([0, 0.05, 0.2], device=device)
    cam_radius = 2.7
    fov_deg = 18.837
    intrinsics = FOV_to_intrinsics(fov_deg, device=device)

    for i in range(5):
        for j in range(5):
            angle_p, angle_y = -0.2*np.pi + i*0.1*np.pi, -0.2*np.pi + j*0.1*np.pi

            cam2world_pose = LookAtPoseSampler.sample(np.pi/2 + angle_y, np.pi/2 + angle_p, cam_pivot, radius=cam_radius, device=device)
            camera_params = torch.cat([cam2world_pose.reshape(-1, 16), intrinsics.reshape(-1, 9)], 1)

            img = G.synthesis(pSp_code, camera_params)['image']
            img_save = (img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8)
            img_save = img_save[0].cpu().numpy()
            Image.fromarray(img_save, 'RGB').save('rendered_faces/'+str(i)+'-'+str(j)+'.png')