From 3de3c13a0fb4d7a35008c26d8b62cfadac6a011a Mon Sep 17 00:00:00 2001 From: Xie Fangyuan Date: Wed, 16 Mar 2022 05:44:17 -0700 Subject: [PATCH] R2n2 (#1124) Summary: 1. Fix https://github.com/facebookresearch/pytorch3d/issues/1115 Change the type annatations of three arguments in the initializer of `R2N2` class. 2. Fix https://github.com/facebookresearch/pytorch3d/issues/1118 Override two functions in `BlenderCamera` class reruired by subclassing `CamerasBase` class. Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/1124 Reviewed By: nikhilaravi Differential Revision: D34890900 Pulled By: bottler fbshipit-source-id: 65c385369a5964ecbb17ab28f279d5284614b487 --- pytorch3d/datasets/r2n2/r2n2.py | 12 ++++++------ pytorch3d/datasets/r2n2/utils.py | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pytorch3d/datasets/r2n2/r2n2.py b/pytorch3d/datasets/r2n2/r2n2.py index a7bb604e..8cce67c6 100644 --- a/pytorch3d/datasets/r2n2/r2n2.py +++ b/pytorch3d/datasets/r2n2/r2n2.py @@ -55,9 +55,9 @@ class R2N2(ShapeNetBase): # pragma: no cover def __init__( self, split: str, - shapenet_dir, - r2n2_dir, - splits_file, + shapenet_dir: str, + r2n2_dir: str, + splits_file: str, return_all_views: bool = True, return_voxels: bool = False, views_rel_path: str = "ShapeNetRendering", @@ -70,9 +70,9 @@ class R2N2(ShapeNetBase): # pragma: no cover Args: split (str): One of (train, val, test). - shapenet_dir (path): Path to ShapeNet core v1. - r2n2_dir (path): Path to the R2N2 dataset. - splits_file (path): File containing the train/val/test splits. + shapenet_dir (str): Path to ShapeNet core v1. + r2n2_dir (str): Path to the R2N2 dataset. + splits_file (str): File containing the train/val/test splits. return_all_views (bool): Indicator of whether or not to load all the views in the split. If set to False, one of the views in the split will be randomly selected and loaded. diff --git a/pytorch3d/datasets/r2n2/utils.py b/pytorch3d/datasets/r2n2/utils.py index a8da0fdf..c5b5f394 100644 --- a/pytorch3d/datasets/r2n2/utils.py +++ b/pytorch3d/datasets/r2n2/utils.py @@ -459,6 +459,12 @@ class BlenderCamera(CamerasBase): # pragma: no cover transform._matrix = self.K.transpose(1, 2).contiguous() return transform + def is_perspective(self): + return False + + def in_ndc(self): + return True + def render_cubified_voxels( voxels: torch.Tensor, shader_type=HardPhongShader, device: Device = "cpu", **kwargs