@@ -49,7 +49,7 @@ class RenderedMeshDatasetMapProvider(DatasetMapProviderBase): # pyre-ignore [13
49
49
if one is available, the data it produces is on the CPU just like
50
50
the data returned by implicitron's other dataset map providers.
51
51
This is because both datasets and models can be large, so implicitron's
52
- GenericModel.forward (etc) expects data on the CPU and only moves
52
+ training loop expects data on the CPU and only moves
53
53
what it needs to the device.
54
54
55
55
For a more detailed explanation of this code, please refer to the
@@ -61,16 +61,23 @@ class RenderedMeshDatasetMapProvider(DatasetMapProviderBase): # pyre-ignore [13
61
61
the cow mesh in the same repo as this code.
62
62
azimuth_range: number of degrees on each side of the start position to
63
63
take samples
64
+ distance: distance from camera centres to the origin.
64
65
resolution: the common height and width of the output images.
65
66
use_point_light: whether to use a particular point light as opposed
66
67
to ambient white.
68
+ gpu_idx: which gpu to use for rendering the mesh.
69
+ path_manager_factory: (Optional) An object that generates an instance of
70
+ PathManager that can translate provided file paths.
71
+ path_manager_factory_class_type: The class type of `path_manager_factory`.
67
72
"""
68
73
69
74
num_views : int = 40
70
75
data_file : Optional [str ] = None
71
76
azimuth_range : float = 180
77
+ distance : float = 2.7
72
78
resolution : int = 128
73
79
use_point_light : bool = True
80
+ gpu_idx : Optional [int ] = 0
74
81
path_manager_factory : PathManagerFactory
75
82
path_manager_factory_class_type : str = "PathManagerFactory"
76
83
@@ -85,8 +92,8 @@ def get_all_train_cameras(self) -> CamerasBase:
85
92
def __post_init__ (self ) -> None :
86
93
super ().__init__ ()
87
94
run_auto_creation (self )
88
- if torch .cuda .is_available ():
89
- device = torch .device ("cuda:0 " )
95
+ if torch .cuda .is_available () and self . gpu_idx is not None :
96
+ device = torch .device (f "cuda:{ self . gpu_idx } " )
90
97
else :
91
98
device = torch .device ("cpu" )
92
99
if self .data_file is None :
@@ -106,13 +113,13 @@ def __post_init__(self) -> None:
106
113
num_views = self .num_views ,
107
114
mesh = mesh ,
108
115
azimuth_range = self .azimuth_range ,
116
+ distance = self .distance ,
109
117
resolution = self .resolution ,
110
118
device = device ,
111
119
use_point_light = self .use_point_light ,
112
120
)
113
121
# pyre-ignore[16]
114
122
self .poses = poses .cpu ()
115
- expand_args_fields (SingleSceneDataset )
116
123
# pyre-ignore[16]
117
124
self .train_dataset = SingleSceneDataset ( # pyre-ignore[28]
118
125
object_name = "cow" ,
@@ -130,6 +137,7 @@ def _generate_cow_renders(
130
137
num_views : int ,
131
138
mesh : Meshes ,
132
139
azimuth_range : float ,
140
+ distance : float ,
133
141
resolution : int ,
134
142
device : torch .device ,
135
143
use_point_light : bool ,
@@ -168,11 +176,11 @@ def _generate_cow_renders(
168
176
else :
169
177
lights = AmbientLights (device = device )
170
178
171
- # Initialize an OpenGL perspective camera that represents a batch of different
179
+ # Initialize a perspective camera that represents a batch of different
172
180
# viewing angles. All the cameras helper methods support mixed type inputs and
173
- # broadcasting. So we can view the camera from the a distance of dist=2.7 , and
181
+ # broadcasting. So we can view the camera from a fixed distance , and
174
182
# then specify elevation and azimuth angles for each viewpoint as tensors.
175
- R , T = look_at_view_transform (dist = 2.7 , elev = elev , azim = azim )
183
+ R , T = look_at_view_transform (dist = distance , elev = elev , azim = azim )
176
184
cameras = FoVPerspectiveCameras (device = device , R = R , T = T )
177
185
178
186
# Define the settings for rasterization and shading.
0 commit comments