get_all_train_cameras

Summary: As part of removing Task, make the dataset code generate the source cameras for itself. There's a small optimization available here, in that the JsonIndexDataset could avoid loading images.

Reviewed By: shapovalov

Differential Revision: D37313423

fbshipit-source-id: 3e5e0b2aabbf9cc51f10547a3523e98c72ad8755
This commit is contained in:
Jeremy Reizenstein
2022-07-06 07:13:41 -07:00
committed by Facebook GitHub Bot
parent 771cf8a328
commit 4e87c2b7f1
12 changed files with 139 additions and 94 deletions

View File

@@ -0,0 +1,42 @@
# 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
from pytorch3d.implicitron.dataset.data_source import ImplicitronDataSource
from pytorch3d.implicitron.tools.config import get_default_args
from pytorch3d.renderer import PerspectiveCameras
from tests.common_testing import TestCaseMixin
# These tests are only run internally, where the data is available.
internal = os.environ.get("FB_TEST", False)
inside_re_worker = os.environ.get("INSIDE_RE_WORKER", False)
skip_tests = not internal or inside_re_worker
@unittest.skipIf(skip_tests, "no data")
class TestDataJsonIndex(TestCaseMixin, unittest.TestCase):
def test_loaders(self):
args = get_default_args(ImplicitronDataSource)
args.dataset_map_provider_class_type = "JsonIndexDatasetMapProvider"
dataset_args = args.dataset_map_provider_JsonIndexDatasetMapProvider_args
dataset_args.category = "skateboard"
dataset_args.dataset_root = "manifold://co3d/tree/extracted"
dataset_args.test_restrict_sequence_id = 0
dataset_args.dataset_JsonIndexDataset_args.limit_sequences_to = 1
data_source = ImplicitronDataSource(**args)
cameras = data_source.get_all_train_cameras()
self.assertIsInstance(cameras, PerspectiveCameras)
self.assertEqual(len(cameras), 81)
data_sets, data_loaders = data_source.get_datasets_and_dataloaders()
self.assertEqual(len(data_sets.train), 81)
self.assertEqual(len(data_sets.val), 102)
self.assertEqual(len(data_sets.test), 102)

View File

@@ -16,6 +16,7 @@ from pytorch3d.implicitron.dataset.llff_dataset_map_provider import (
LlffDatasetMapProvider,
)
from pytorch3d.implicitron.tools.config import expand_args_fields, get_default_args
from pytorch3d.renderer import PerspectiveCameras
from tests.common_testing import TestCaseMixin
@@ -123,3 +124,7 @@ class TestDataLlff(TestCaseMixin, unittest.TestCase):
for i in data_loaders.test:
self.assertEqual(i.frame_type, ["unseen"])
self.assertEqual(i.image_rgb.shape, (1, 3, 800, 800))
cameras = data_source.get_all_train_cameras()
self.assertIsInstance(cameras, PerspectiveCameras)
self.assertEqual(len(cameras), 100)

View File

@@ -24,11 +24,7 @@ from pytorch3d.implicitron.tools.config import expand_args_fields, registry
from pytorch3d.implicitron.tools.metric_utils import calc_psnr, eval_depth
from pytorch3d.implicitron.tools.utils import dataclass_to_cuda_
if os.environ.get("FB_TEST", False):
from .common_resources import get_skateboard_data, provide_lpips_vgg
else:
from common_resources import get_skateboard_data, provide_lpips_vgg
from .common_resources import get_skateboard_data, provide_lpips_vgg
class TestEvaluation(unittest.TestCase):