()
| 571 | |
| 572 | |
| 573 | def train(): |
| 574 | |
| 575 | # Load data |
| 576 | |
| 577 | if args.dataset_type == 'llff': |
| 578 | images, poses, bds, render_poses, i_test = load_llff_data(args.datadir, args.factor, |
| 579 | recenter=True, bd_factor=.75, |
| 580 | spherify=args.spherify) |
| 581 | hwf = poses[0,:3,-1] |
| 582 | poses = poses[:,:3,:4] |
| 583 | print('Loaded llff', images.shape, render_poses.shape, hwf, args.datadir) |
| 584 | if not isinstance(i_test, list): |
| 585 | i_test = [i_test] |
| 586 | |
| 587 | if args.llffhold > 0: |
| 588 | print('Auto LLFF holdout,', args.llffhold) |
| 589 | i_test = np.arange(images.shape[0])[::args.llffhold] |
| 590 | |
| 591 | i_val = i_test |
| 592 | i_trainhold = np.array([i for i in np.arange(int(images.shape[0])) if |
| 593 | (i not in i_test and i not in i_val)]) |
| 594 | |
| 595 | i_holdout = i_trainhold[args.init_image:] |
| 596 | i_train = i_trainhold[:args.init_image] |
| 597 | |
| 598 | print('DEFINING BOUNDS') |
| 599 | if args.no_ndc: |
| 600 | near = np.ndarray.min(bds) * .9 |
| 601 | far = np.ndarray.max(bds) * 1. |
| 602 | |
| 603 | else: |
| 604 | near = 0. |
| 605 | far = 1. |
| 606 | print('NEAR FAR', near, far) |
| 607 | |
| 608 | elif args.dataset_type == 'blender': |
| 609 | images, poses, render_poses, hwf, i_split = load_blender_data(args.datadir, args.half_res, args.testskip) |
| 610 | print('Loaded blender', images.shape, render_poses.shape, hwf, args.datadir) |
| 611 | i_train, i_holdout, i_val, i_test = i_split |
| 612 | |
| 613 | near = 2. |
| 614 | far = 6. |
| 615 | |
| 616 | if args.white_bkgd: |
| 617 | images = images[...,:3]*images[...,-1:] + (1.-images[...,-1:]) |
| 618 | else: |
| 619 | images = images[...,:3] |
| 620 | |
| 621 | else: |
| 622 | print('Unknown dataset type', args.dataset_type, 'exiting') |
| 623 | return |
| 624 | |
| 625 | # Cast intrinsics to right types |
| 626 | H, W, focal = hwf |
| 627 | H, W = int(H), int(W) |
| 628 | hwf = [H, W, focal] |
| 629 | |
| 630 | if args.render_test: |
no test coverage detected