(args, train_dl, val_dl, hwf, start, render_kwargs_test, decoder_coarse=None, decoder_fine=None)
| 458 | return rgbs, disps |
| 459 | |
| 460 | def render_test(args, train_dl, val_dl, hwf, start, render_kwargs_test, decoder_coarse=None, decoder_fine=None): |
| 461 | |
| 462 | ### Eval Training set result |
| 463 | trainsavedir = os.path.join(args.basedir, args.expname, 'evaluate_train_{}_{:06d}'.format('test' if args.render_test else 'path', start)) |
| 464 | os.makedirs(trainsavedir, exist_ok=True) |
| 465 | images_train = [] |
| 466 | poses_train = [] |
| 467 | index_train = [] |
| 468 | # views from validation set |
| 469 | for img, pose, img_idx in train_dl: |
| 470 | img_val = img.permute(0,2,3,1) # (1,240,360,3) |
| 471 | pose_val = torch.zeros(1,4,4) |
| 472 | pose_val[0,:3,:4] = pose.reshape(3,4)[:3,:4] # (1,3,4)) |
| 473 | pose_val[0,3,3] = 1. |
| 474 | images_train.append(img_val) |
| 475 | poses_train.append(pose_val) |
| 476 | index_train.append(img_idx) |
| 477 | |
| 478 | images_train = torch.cat(images_train, dim=0).numpy() |
| 479 | poses_train = torch.cat(poses_train, dim=0).to(device) |
| 480 | index_train = torch.cat(index_train, dim=0).to(device) |
| 481 | print('train poses shape', poses_train.shape) |
| 482 | |
| 483 | with torch.no_grad(): |
| 484 | torch.set_default_tensor_type('torch.cuda.FloatTensor') |
| 485 | rgbs, disps = render_path(args, poses_train.to(device), hwf, args.chunk, render_kwargs_test, gt_imgs=images_train, savedir=trainsavedir, img_ids=index_train) |
| 486 | torch.set_default_tensor_type('torch.FloatTensor') |
| 487 | print('Saved train set') |
| 488 | if args.render_video_train: |
| 489 | print('Saving trainset as video', rgbs.shape, disps.shape) |
| 490 | moviebase = os.path.join(args.basedir, args.expname, '{}_trainset_{:06d}_'.format(args.expname, start)) |
| 491 | imageio.mimwrite(moviebase + 'train_rgb.mp4', to8b(rgbs), fps=15, quality=8) |
| 492 | imageio.mimwrite(moviebase + 'train_disp.mp4', to8b(disps / np.max(disps)), fps=15, quality=8) |
| 493 | del images_train |
| 494 | del poses_train |
| 495 | # clean GPU memory after testing |
| 496 | torch.cuda.empty_cache() |
| 497 | |
| 498 | ### Eval Validation set result |
| 499 | testsavedir = os.path.join(args.basedir, args.expname, 'evaluate_val_{}_{:06d}'.format('test' if args.render_test else 'path', start)) |
| 500 | os.makedirs(testsavedir, exist_ok=True) |
| 501 | images_val = [] |
| 502 | poses_val = [] |
| 503 | index_val = [] |
| 504 | # views from validation set |
| 505 | for img, pose, img_idx in val_dl: |
| 506 | img_val = img.permute(0,2,3,1) # (1,240,360,3) |
| 507 | pose_val = torch.zeros(1,4,4) |
| 508 | pose_val[0,:3,:4] = pose.reshape(3,4)[:3,:4] # (1,3,4)) |
| 509 | pose_val[0,3,3] = 1. |
| 510 | images_val.append(img_val) |
| 511 | poses_val.append(pose_val) |
| 512 | index_val.append(img_idx) |
| 513 | |
| 514 | images_val = torch.cat(images_val, dim=0).numpy() |
| 515 | poses_val = torch.cat(poses_val, dim=0).to(device) |
| 516 | index_val = torch.cat(index_val, dim=0).to(device) |
| 517 | print('test poses shape', poses_val.shape) |
nothing calls this directly
no test coverage detected