(self,
root_dir='objaverse/',
input_view_num=6,
input_image_size=320,
fov=30,
)
| 240 | |
| 241 | class ValidationData(Dataset): |
| 242 | def __init__(self, |
| 243 | root_dir='objaverse/', |
| 244 | input_view_num=6, |
| 245 | input_image_size=320, |
| 246 | fov=30, |
| 247 | ): |
| 248 | self.root_dir = Path(root_dir) |
| 249 | self.input_view_num = input_view_num |
| 250 | self.input_image_size = input_image_size |
| 251 | self.fov = fov |
| 252 | |
| 253 | self.paths = sorted(os.listdir(self.root_dir)) |
| 254 | print('============= length of dataset %d =============' % len(self.paths)) |
| 255 | |
| 256 | cam_distance = 4.0 |
| 257 | azimuths = np.array([30, 90, 150, 210, 270, 330]) |
| 258 | elevations = np.array([20, -10, 20, -10, 20, -10]) |
| 259 | azimuths = np.deg2rad(azimuths) |
| 260 | elevations = np.deg2rad(elevations) |
| 261 | |
| 262 | x = cam_distance * np.cos(elevations) * np.cos(azimuths) |
| 263 | y = cam_distance * np.cos(elevations) * np.sin(azimuths) |
| 264 | z = cam_distance * np.sin(elevations) |
| 265 | |
| 266 | cam_locations = np.stack([x, y, z], axis=-1) |
| 267 | cam_locations = torch.from_numpy(cam_locations).float() |
| 268 | c2ws = center_looking_at_camera_pose(cam_locations) |
| 269 | self.c2ws = c2ws.float() |
| 270 | self.Ks = FOV_to_intrinsics(self.fov).unsqueeze(0).repeat(6, 1, 1).float() |
| 271 | |
| 272 | render_c2ws = get_circular_camera_poses(M=8, radius=cam_distance, elevation=20.0) |
| 273 | render_Ks = FOV_to_intrinsics(self.fov).unsqueeze(0).repeat(render_c2ws.shape[0], 1, 1) |
| 274 | self.render_c2ws = render_c2ws.float() |
| 275 | self.render_Ks = render_Ks.float() |
| 276 | |
| 277 | def __len__(self): |
| 278 | return len(self.paths) |
nothing calls this directly
no test coverage detected