MCPcopy
hub / github.com/yerfor/GeneFacePlusPlus / test_gui_with_editable_data

Method test_gui_with_editable_data

tasks/radnerfs/radnerf.py:338–385  ·  view source on GitHub ↗
(self, pose, intrinsics, W, H, cond_wins, index=0, bg_color=None, spp=1, downscale=1)

Source from the content-addressed store, hash-verified

336
337 ### GUI utils
338 def test_gui_with_editable_data(self, pose, intrinsics, W, H, cond_wins, index=0, bg_color=None, spp=1, downscale=1):
339 # def test_gui_with_edited_data(self, pose, intrinsics, W, H, cond_wins, index=0, bg_color=None, downscale=1):
340 # render resolution (may need downscale to for better frame rate)
341 rH = int(H * downscale)
342 rW = int(W * downscale)
343 intrinsics = intrinsics * downscale
344
345 cond_wins = cond_wins.cuda()
346 pose = torch.from_numpy(pose).unsqueeze(0).cuda()
347 rays = get_rays(pose, intrinsics, rH, rW, -1)
348 bg_coords = get_bg_coords(rH, rW, 'cuda')
349
350 sample = {
351 'rays_o': rays['rays_o'].cuda(),
352 'rays_d': rays['rays_d'].cuda(),
353 'H': rH,
354 'W': rW,
355 'cond_wins': cond_wins,
356 'idx': [index], # support choosing index for individual codes
357 'pose': convert_poses(pose),
358 'bg_coords': bg_coords,
359 'bg_img': bg_color.cuda()
360 }
361
362 self.model.eval()
363 with torch.no_grad():
364 with torch.cuda.amp.autocast(enabled=hparams['amp']):
365 # here spp is used as perturb random seed!
366 # face: do not perturb for the first spp, else lead to scatters.
367 infer_outputs = self.run_model(sample, infer=True)
368 preds = infer_outputs['rgb_map'].reshape([1,rH, rW, 3])
369 preds_depth = infer_outputs['depth_map'].reshape([1, rH, rW])
370
371 # interpolation to the original resolution
372 if downscale != 1:
373 # TODO: have to permute twice with torch...
374 preds = F.interpolate(preds.permute(0, 3, 1, 2), size=(H, W), mode='bilinear').permute(0, 2, 3, 1).contiguous()
375 preds_depth = F.interpolate(preds_depth.unsqueeze(1), size=(H, W), mode='nearest').squeeze(1)
376
377 pred = preds[0].detach().cpu().numpy()
378 pred_depth = preds_depth[0].detach().cpu().numpy()
379
380 outputs = {
381 'image': pred,
382 'depth': pred_depth,
383 }
384
385 return outputs
386
387 # [GUI] test with provided data
388 def test_gui_with_data(self, sample, target_W, target_H):

Callers

nothing calls this directly

Calls 4

run_modelMethod · 0.95
get_raysFunction · 0.90
get_bg_coordsFunction · 0.90
convert_posesFunction · 0.90

Tested by

no test coverage detected