allow get_default_args(JsonIndexDataset)

Summary: Changes to JsonIndexDataset to make it fit with OmegaConf.structured. Also match some default values to what the provider defaults to.

Reviewed By: davnov134

Differential Revision: D36666704

fbshipit-source-id: 65b059a1dbaa240ce85c3e8762b7c3db3b5a6e75
This commit is contained in:
Jeremy Reizenstein
2022-06-10 12:22:46 -07:00
committed by Facebook GitHub Bot
parent 8bc0a04e86
commit 1fb268dea6
5 changed files with 90 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ import unittest
from omegaconf import OmegaConf
from pytorch3d.implicitron.dataset.data_source import ImplicitronDataSource
from pytorch3d.implicitron.dataset.json_index_dataset import JsonIndexDataset
from pytorch3d.implicitron.tools.config import get_default_args
from tests.common_testing import get_tests_dir
@@ -20,6 +21,33 @@ class TestDataSource(unittest.TestCase):
def setUp(self):
self.maxDiff = None
def _test_omegaconf_generic_failure(self):
# OmegaConf possible bug - this is why we need _GenericWorkaround
from dataclasses import dataclass
import torch
@dataclass
class D(torch.utils.data.Dataset[int]):
a: int = 3
OmegaConf.structured(D)
def _test_omegaconf_ListList(self):
# Demo that OmegaConf doesn't support nested lists
from dataclasses import dataclass
from typing import Sequence
@dataclass
class A:
a: Sequence[Sequence[int]] = ((32,),)
OmegaConf.structured(A)
def test_JsonIndexDataset_args(self):
# test that JsonIndexDataset works with get_default_args
get_default_args(JsonIndexDataset)
def test_one(self):
with unittest.mock.patch.dict(os.environ, {"CO3D_DATASET_ROOT": ""}):
cfg = get_default_args(ImplicitronDataSource)

View File

@@ -51,6 +51,7 @@ class TestEvaluation(unittest.TestCase):
image_height=self.image_size,
image_width=self.image_size,
box_crop=True,
remove_empty_masks=False,
path_manager=path_manager,
)
self.bg_color = (0.0, 0.0, 0.0)