visualize_reconstruction fixes

Summary: Various fixes to get visualize_reconstruction running, and an interactive test for it.

Reviewed By: kjchalup

Differential Revision: D39286691

fbshipit-source-id: 88735034cc01736b24735bcb024577e6ab7ed336
This commit is contained in:
Jeremy Reizenstein
2022-09-07 20:10:07 -07:00
committed by Facebook GitHub Bot
parent 34ad77b841
commit 6e25fe8cb3
8 changed files with 125 additions and 58 deletions

View File

@@ -13,16 +13,7 @@ from hydra import compose, initialize_config_dir
from omegaconf import OmegaConf
from .. import experiment
from .utils import intercept_logs
def interactive_testing_requested() -> bool:
"""
Certain tests are only useful when run interactively, and so are not regularly run.
These are activated by this funciton returning True, which the user requests by
setting the environment variable `PYTORCH3D_INTERACTIVE_TESTING` to 1.
"""
return os.environ.get("PYTORCH3D_INTERACTIVE_TESTING", "") == "1"
from .utils import interactive_testing_requested, intercept_logs
internal = os.environ.get("FB_TEST", False)

View File

@@ -0,0 +1,27 @@
# 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 .. import visualize_reconstruction
from .utils import interactive_testing_requested
internal = os.environ.get("FB_TEST", False)
class TestVisualize(unittest.TestCase):
def test_from_defaults(self):
if not interactive_testing_requested():
return
checkpoint_dir = os.environ["exp_dir"]
argv = [
f"exp_dir={checkpoint_dir}",
"n_eval_cameras=40",
"render_size=[64,64]",
"video_size=[256,256]",
]
visualize_reconstruction.main(argv)

View File

@@ -6,6 +6,7 @@
import contextlib
import logging
import os
import re
@@ -28,3 +29,12 @@ def intercept_logs(logger_name: str, regexp: str):
yield intercepted_messages
finally:
logger.removeFilter(interceptor)
def interactive_testing_requested() -> bool:
"""
Certain tests are only useful when run interactively, and so are not regularly run.
These are activated by this funciton returning True, which the user requests by
setting the environment variable `PYTORCH3D_INTERACTIVE_TESTING` to 1.
"""
return os.environ.get("PYTORCH3D_INTERACTIVE_TESTING", "") == "1"