mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30:35 +08:00
Extract finding directories for test data
Summary: Make common functions for finding directories where test data is found, instead of lots of tests using their own `__file__` while trying to get ./tests/data and the tutorials data. Reviewed By: nikhilaravi Differential Revision: D27633701 fbshipit-source-id: 1467bb6018cea16eba3cab097d713116d51071e9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
24ee279005
commit
1216b5765a
@@ -6,11 +6,15 @@ Sanity checks for output images from the renderer.
|
||||
"""
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from common_testing import TestCaseMixin, load_rgb_image
|
||||
from common_testing import (
|
||||
TestCaseMixin,
|
||||
load_rgb_image,
|
||||
get_pytorch3d_dir,
|
||||
get_tests_dir,
|
||||
)
|
||||
from PIL import Image
|
||||
from pytorch3d.io import load_obj
|
||||
from pytorch3d.renderer.cameras import (
|
||||
@@ -46,7 +50,7 @@ from pytorch3d.utils.torus import torus
|
||||
# If DEBUG=True, save out images generated in the tests for debugging.
|
||||
# All saved images have prefix DEBUG_
|
||||
DEBUG = False
|
||||
DATA_DIR = Path(__file__).resolve().parent / "data"
|
||||
DATA_DIR = get_tests_dir() / "data"
|
||||
|
||||
|
||||
class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
@@ -384,7 +388,7 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
The pupils in the eyes of the cow should always be looking to the left.
|
||||
"""
|
||||
device = torch.device("cuda:0")
|
||||
obj_dir = Path(__file__).resolve().parent.parent / "docs/tutorials/data"
|
||||
obj_dir = get_pytorch3d_dir() / "docs/tutorials/data"
|
||||
obj_filename = obj_dir / "cow_mesh/cow.obj"
|
||||
|
||||
# Load mesh + texture
|
||||
@@ -966,7 +970,7 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
Also check that the backward pass for texture atlas rendering is differentiable.
|
||||
"""
|
||||
device = torch.device("cuda:0")
|
||||
obj_dir = Path(__file__).resolve().parent.parent / "docs/tutorials/data"
|
||||
obj_dir = get_pytorch3d_dir() / "docs/tutorials/data"
|
||||
obj_filename = obj_dir / "cow_mesh/cow.obj"
|
||||
|
||||
# Load mesh and texture as a per face texture atlas.
|
||||
|
||||
Reference in New Issue
Block a user