mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 05:40:34 +08:00
provide cow dataset
Summary: Make a dummy single-scene dataset using the code from generate_cow_renders (used in existing NeRF tutorials) Reviewed By: kjchalup Differential Revision: D38116910 fbshipit-source-id: 8db6df7098aa221c81d392e5cd21b0e67f65bd70
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1b0584f7bd
commit
14bd5e28e8
@@ -2,6 +2,6 @@
|
||||
|
||||
This is copied version of docs/tutorials/data/cow_mesh with removed line 6159 (usemtl material_1) to test behavior without usemtl material_1 declaration.
|
||||
|
||||
Thank you to Keenen Crane for allowing the cow mesh model to be used freely in the public domain.
|
||||
Thank you to Keenan Crane for allowing the cow mesh model to be used freely in the public domain.
|
||||
|
||||
###### Source: http://www.cs.cmu.edu/~kmcrane/Projects/ModelRepository/
|
||||
|
||||
@@ -90,6 +90,15 @@ dataset_map_provider_LlffDatasetMapProvider_args:
|
||||
n_known_frames_for_test: null
|
||||
path_manager_factory_PathManagerFactory_args:
|
||||
silence_logs: true
|
||||
dataset_map_provider_RenderedMeshDatasetMapProvider_args:
|
||||
num_views: 40
|
||||
data_file: null
|
||||
azimuth_range: 180.0
|
||||
resolution: 128
|
||||
use_point_light: true
|
||||
path_manager_factory_class_type: PathManagerFactory
|
||||
path_manager_factory_PathManagerFactory_args:
|
||||
silence_logs: true
|
||||
data_loader_map_provider_SequenceDataLoaderMapProvider_args:
|
||||
batch_size: 1
|
||||
num_workers: 0
|
||||
|
||||
57
tests/implicitron/test_data_cow.py
Normal file
57
tests/implicitron/test_data_cow.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD-style license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import torch
|
||||
from pytorch3d.implicitron.dataset.dataset_base import FrameData
|
||||
from pytorch3d.implicitron.dataset.rendered_mesh_dataset_map_provider import (
|
||||
RenderedMeshDatasetMapProvider,
|
||||
)
|
||||
from pytorch3d.implicitron.tools.config import expand_args_fields
|
||||
from pytorch3d.renderer import FoVPerspectiveCameras
|
||||
from tests.common_testing import TestCaseMixin
|
||||
|
||||
|
||||
inside_re_worker = os.environ.get("INSIDE_RE_WORKER", False)
|
||||
|
||||
|
||||
class TestDataCow(TestCaseMixin, unittest.TestCase):
|
||||
def test_simple(self):
|
||||
if inside_re_worker:
|
||||
return
|
||||
expand_args_fields(RenderedMeshDatasetMapProvider)
|
||||
self._runtest(use_point_light=True, num_views=4)
|
||||
self._runtest(use_point_light=False, num_views=4)
|
||||
|
||||
def _runtest(self, **kwargs):
|
||||
provider = RenderedMeshDatasetMapProvider(**kwargs)
|
||||
dataset_map = provider.get_dataset_map()
|
||||
known_matrix = torch.zeros(1, 4, 4)
|
||||
known_matrix[0, 0, 0] = 1.7321
|
||||
known_matrix[0, 1, 1] = 1.7321
|
||||
known_matrix[0, 2, 2] = 1.0101
|
||||
known_matrix[0, 3, 2] = -1.0101
|
||||
known_matrix[0, 2, 3] = 1
|
||||
|
||||
self.assertIsNone(dataset_map.val)
|
||||
self.assertIsNone(dataset_map.test)
|
||||
self.assertEqual(len(dataset_map.train), provider.num_views)
|
||||
|
||||
value = dataset_map.train[0]
|
||||
self.assertIsInstance(value, FrameData)
|
||||
|
||||
self.assertEqual(value.image_rgb.shape, (3, 128, 128))
|
||||
self.assertEqual(value.fg_probability.shape, (1, 128, 128))
|
||||
# corner of image is background
|
||||
self.assertEqual(value.fg_probability[0, 0, 0], 0)
|
||||
self.assertEqual(value.fg_probability.max(), 1.0)
|
||||
self.assertIsInstance(value.camera, FoVPerspectiveCameras)
|
||||
self.assertEqual(len(value.camera), 1)
|
||||
self.assertIsNone(value.camera.K)
|
||||
matrix = value.camera.get_projection_transform().get_matrix()
|
||||
self.assertClose(matrix, known_matrix, atol=1e-4)
|
||||
Reference in New Issue
Block a user