diff --git a/docs/tutorials/utils/generate_cow_renders.py b/docs/tutorials/utils/generate_cow_renders.py index 01b6087c..eaf0ced5 100644 --- a/docs/tutorials/utils/generate_cow_renders.py +++ b/docs/tutorials/utils/generate_cow_renders.py @@ -12,13 +12,13 @@ from pytorch3d.io import load_objs_as_meshes from pytorch3d.renderer import ( BlendParams, FoVPerspectiveCameras, + look_at_view_transform, MeshRasterizer, MeshRenderer, PointLights, RasterizationSettings, SoftPhongShader, SoftSilhouetteShader, - look_at_view_transform, ) diff --git a/projects/nerf/nerf/eval_video_utils.py b/projects/nerf/nerf/eval_video_utils.py index 378e75d4..a84e4b17 100644 --- a/projects/nerf/nerf/eval_video_utils.py +++ b/projects/nerf/nerf/eval_video_utils.py @@ -8,7 +8,7 @@ import math from typing import Tuple import torch -from pytorch3d.renderer import PerspectiveCameras, look_at_view_transform +from pytorch3d.renderer import look_at_view_transform, PerspectiveCameras from torch.utils.data.dataset import Dataset diff --git a/projects/nerf/nerf/implicit_function.py b/projects/nerf/nerf/implicit_function.py index 472a4a35..ef1278bb 100644 --- a/projects/nerf/nerf/implicit_function.py +++ b/projects/nerf/nerf/implicit_function.py @@ -8,7 +8,7 @@ from typing import Tuple import torch from pytorch3d.common.linear_with_repeat import LinearWithRepeat -from pytorch3d.renderer import HarmonicEmbedding, RayBundle, ray_bundle_to_ray_points +from pytorch3d.renderer import HarmonicEmbedding, ray_bundle_to_ray_points, RayBundle def _xavier_init(linear): diff --git a/pytorch3d/common/linear_with_repeat.py b/pytorch3d/common/linear_with_repeat.py index c9f62355..2dd477be 100644 --- a/pytorch3d/common/linear_with_repeat.py +++ b/pytorch3d/common/linear_with_repeat.py @@ -9,7 +9,7 @@ from typing import Tuple import torch import torch.nn.functional as F -from torch.nn import Parameter, init +from torch.nn import init, Parameter class LinearWithRepeat(torch.nn.Module): diff --git a/pytorch3d/datasets/__init__.py b/pytorch3d/datasets/__init__.py index 191cbb0e..3dbee1eb 100644 --- a/pytorch3d/datasets/__init__.py +++ b/pytorch3d/datasets/__init__.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from .r2n2 import R2N2, BlenderCamera, collate_batched_R2N2, render_cubified_voxels +from .r2n2 import BlenderCamera, collate_batched_R2N2, R2N2, render_cubified_voxels from .shapenet import ShapeNetCore from .utils import collate_batched_meshes diff --git a/pytorch3d/datasets/r2n2/r2n2.py b/pytorch3d/datasets/r2n2/r2n2.py index 8cce67c6..e94d85a8 100644 --- a/pytorch3d/datasets/r2n2/r2n2.py +++ b/pytorch3d/datasets/r2n2/r2n2.py @@ -19,8 +19,8 @@ from pytorch3d.renderer import HardPhongShader from tabulate import tabulate from .utils import ( - BlenderCamera, align_bbox, + BlenderCamera, compute_extrinsic_matrix, read_binvox_coords, voxelize, diff --git a/pytorch3d/implicitron/dataset/implicitron_dataset.py b/pytorch3d/implicitron/dataset/implicitron_dataset.py index 0d5294ad..65fe43a3 100644 --- a/pytorch3d/implicitron/dataset/implicitron_dataset.py +++ b/pytorch3d/implicitron/dataset/implicitron_dataset.py @@ -39,7 +39,7 @@ from PIL import Image from pytorch3d.io import IO from pytorch3d.renderer.camera_utils import join_cameras_as_batch from pytorch3d.renderer.cameras import CamerasBase, PerspectiveCameras -from pytorch3d.structures.pointclouds import Pointclouds, join_pointclouds_as_batch +from pytorch3d.structures.pointclouds import join_pointclouds_as_batch, Pointclouds from . import types diff --git a/pytorch3d/implicitron/dataset/visualize.py b/pytorch3d/implicitron/dataset/visualize.py index 37290ecd..4daa5f45 100644 --- a/pytorch3d/implicitron/dataset/visualize.py +++ b/pytorch3d/implicitron/dataset/visualize.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from typing import Optional, Tuple, cast +from typing import cast, Optional, Tuple import torch from pytorch3d.implicitron.tools.point_cloud_utils import get_rgbd_point_cloud diff --git a/pytorch3d/implicitron/eval_demo.py b/pytorch3d/implicitron/eval_demo.py index 150f5a0c..59d27ae3 100644 --- a/pytorch3d/implicitron/eval_demo.py +++ b/pytorch3d/implicitron/eval_demo.py @@ -8,7 +8,7 @@ import copy import dataclasses import os -from typing import Optional, cast +from typing import cast, Optional import lpips import torch diff --git a/pytorch3d/implicitron/models/implicit_function/neural_radiance_field.py b/pytorch3d/implicitron/models/implicit_function/neural_radiance_field.py index 019becef..0c6e6e30 100644 --- a/pytorch3d/implicitron/models/implicit_function/neural_radiance_field.py +++ b/pytorch3d/implicitron/models/implicit_function/neural_radiance_field.py @@ -11,7 +11,7 @@ from typing import List, Optional import torch from pytorch3d.common.linear_with_repeat import LinearWithRepeat from pytorch3d.implicitron.tools.config import registry -from pytorch3d.renderer import RayBundle, ray_bundle_to_ray_points +from pytorch3d.renderer import ray_bundle_to_ray_points, RayBundle from pytorch3d.renderer.cameras import CamerasBase from pytorch3d.renderer.implicit import HarmonicEmbedding diff --git a/pytorch3d/implicitron/models/implicit_function/scene_representation_networks.py b/pytorch3d/implicitron/models/implicit_function/scene_representation_networks.py index ce3389e4..faf6fdfe 100644 --- a/pytorch3d/implicitron/models/implicit_function/scene_representation_networks.py +++ b/pytorch3d/implicitron/models/implicit_function/scene_representation_networks.py @@ -1,13 +1,13 @@ # @lint-ignore-every LICENSELINT # Adapted from https://github.com/vsitzmann/scene-representation-networks # Copyright (c) 2019 Vincent Sitzmann -from typing import Any, Optional, Tuple, cast +from typing import Any, cast, Optional, Tuple import torch from pytorch3d.common.linear_with_repeat import LinearWithRepeat from pytorch3d.implicitron.third_party import hyperlayers, pytorch_prototyping from pytorch3d.implicitron.tools.config import Configurable, registry, run_auto_creation -from pytorch3d.renderer import RayBundle, ray_bundle_to_ray_points +from pytorch3d.renderer import ray_bundle_to_ray_points, RayBundle from pytorch3d.renderer.cameras import CamerasBase from pytorch3d.renderer.implicit import HarmonicEmbedding diff --git a/pytorch3d/implicitron/models/view_pooling/feature_aggregation.py b/pytorch3d/implicitron/models/view_pooling/feature_aggregation.py index 1ed6b481..9cdde134 100644 --- a/pytorch3d/implicitron/models/view_pooling/feature_aggregation.py +++ b/pytorch3d/implicitron/models/view_pooling/feature_aggregation.py @@ -13,7 +13,7 @@ import torch.nn.functional as F from pytorch3d.implicitron.models.view_pooling.view_sampling import ( cameras_points_cartesian_product, ) -from pytorch3d.implicitron.tools.config import ReplaceableBase, registry +from pytorch3d.implicitron.tools.config import registry, ReplaceableBase from pytorch3d.ops import wmean from pytorch3d.renderer.cameras import CamerasBase diff --git a/pytorch3d/implicitron/tools/eval_video_trajectory.py b/pytorch3d/implicitron/tools/eval_video_trajectory.py index d9afb873..0c0f65ae 100644 --- a/pytorch3d/implicitron/tools/eval_video_trajectory.py +++ b/pytorch3d/implicitron/tools/eval_video_trajectory.py @@ -10,7 +10,7 @@ from typing import Optional, Tuple import torch from pytorch3d.common.compat import eigh from pytorch3d.implicitron.tools.circle_fitting import fit_circle_in_3d -from pytorch3d.renderer import PerspectiveCameras, look_at_view_transform +from pytorch3d.renderer import look_at_view_transform, PerspectiveCameras from pytorch3d.transforms import Scale diff --git a/pytorch3d/implicitron/tools/point_cloud_utils.py b/pytorch3d/implicitron/tools/point_cloud_utils.py index 756f1229..c1b68374 100644 --- a/pytorch3d/implicitron/tools/point_cloud_utils.py +++ b/pytorch3d/implicitron/tools/point_cloud_utils.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. -from typing import Optional, Tuple, cast +from typing import cast, Optional, Tuple import torch import torch.nn.functional as Fu diff --git a/pytorch3d/io/experimental_gltf_io.py b/pytorch3d/io/experimental_gltf_io.py index d2984edd..1dd3d164 100644 --- a/pytorch3d/io/experimental_gltf_io.py +++ b/pytorch3d/io/experimental_gltf_io.py @@ -42,18 +42,18 @@ from base64 import b64decode from collections import deque from enum import IntEnum from io import BytesIO -from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union, cast +from typing import Any, BinaryIO, cast, Dict, List, Optional, Tuple, Union import numpy as np import torch from iopath.common.file_io import PathManager from PIL import Image -from pytorch3d.io.utils import PathOrStr, _open_file +from pytorch3d.io.utils import _open_file, PathOrStr from pytorch3d.renderer.mesh import TexturesBase, TexturesUV, TexturesVertex -from pytorch3d.structures import Meshes, join_meshes_as_scene -from pytorch3d.transforms import Transform3d, quaternion_to_matrix +from pytorch3d.structures import join_meshes_as_scene, Meshes +from pytorch3d.transforms import quaternion_to_matrix, Transform3d -from .pluggable_formats import MeshFormatInterpreter, endswith +from .pluggable_formats import endswith, MeshFormatInterpreter _GLTF_MAGIC = 0x46546C67 diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index 42571de8..ca6faf41 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -18,11 +18,11 @@ from iopath.common.file_io import PathManager from PIL import Image from pytorch3d.common.datatypes import Device from pytorch3d.io.mtl_io import load_mtl, make_mesh_texture_atlas -from pytorch3d.io.utils import PathOrStr, _check_faces_indices, _make_tensor, _open_file +from pytorch3d.io.utils import _check_faces_indices, _make_tensor, _open_file, PathOrStr from pytorch3d.renderer import TexturesAtlas, TexturesUV -from pytorch3d.structures import Meshes, join_meshes_as_batch +from pytorch3d.structures import join_meshes_as_batch, Meshes -from .pluggable_formats import MeshFormatInterpreter, endswith +from .pluggable_formats import endswith, MeshFormatInterpreter # Faces & Aux type returned from load_obj function. diff --git a/pytorch3d/io/off_io.py b/pytorch3d/io/off_io.py index 607236f8..aa5e5d1b 100644 --- a/pytorch3d/io/off_io.py +++ b/pytorch3d/io/off_io.py @@ -13,16 +13,16 @@ This format is introduced, for example, at http://www.geomview.org/docs/html/OFF.html . """ import warnings -from typing import Optional, Tuple, Union, cast +from typing import cast, Optional, Tuple, Union import numpy as np import torch from iopath.common.file_io import PathManager -from pytorch3d.io.utils import PathOrStr, _check_faces_indices, _open_file +from pytorch3d.io.utils import _check_faces_indices, _open_file, PathOrStr from pytorch3d.renderer import TexturesAtlas, TexturesVertex from pytorch3d.structures import Meshes -from .pluggable_formats import MeshFormatInterpreter, endswith +from .pluggable_formats import endswith, MeshFormatInterpreter def _is_line_empty(line: Union[str, bytes]) -> bool: diff --git a/pytorch3d/io/ply_io.py b/pytorch3d/io/ply_io.py index da803d00..77cd8fbc 100644 --- a/pytorch3d/io/ply_io.py +++ b/pytorch3d/io/ply_io.py @@ -21,14 +21,14 @@ from typing import List, Optional, Tuple import numpy as np import torch from iopath.common.file_io import PathManager -from pytorch3d.io.utils import PathOrStr, _check_faces_indices, _make_tensor, _open_file +from pytorch3d.io.utils import _check_faces_indices, _make_tensor, _open_file, PathOrStr from pytorch3d.renderer import TexturesVertex from pytorch3d.structures import Meshes, Pointclouds from .pluggable_formats import ( + endswith, MeshFormatInterpreter, PointcloudFormatInterpreter, - endswith, ) diff --git a/pytorch3d/io/utils.py b/pytorch3d/io/utils.py index 1dd2d586..e0bd796b 100644 --- a/pytorch3d/io/utils.py +++ b/pytorch3d/io/utils.py @@ -7,7 +7,7 @@ import contextlib import pathlib import warnings -from typing import IO, ContextManager, Optional, Union +from typing import ContextManager, IO, Optional, Union import numpy as np import torch diff --git a/pytorch3d/ops/points_alignment.py b/pytorch3d/ops/points_alignment.py index eaae3f9d..aa4552db 100644 --- a/pytorch3d/ops/points_alignment.py +++ b/pytorch3d/ops/points_alignment.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. import warnings -from typing import TYPE_CHECKING, List, NamedTuple, Optional, Union +from typing import List, NamedTuple, Optional, TYPE_CHECKING, Union import torch from pytorch3d.ops import knn_points diff --git a/pytorch3d/ops/utils.py b/pytorch3d/ops/utils.py index a6fb6d7f..134e49b6 100644 --- a/pytorch3d/ops/utils.py +++ b/pytorch3d/ops/utils.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from typing import TYPE_CHECKING, Optional, Tuple, Union +from typing import Optional, Tuple, TYPE_CHECKING, Union import torch diff --git a/pytorch3d/renderer/__init__.py b/pytorch3d/renderer/__init__.py index 2edce601..ef3daf0e 100644 --- a/pytorch3d/renderer/__init__.py +++ b/pytorch3d/renderer/__init__.py @@ -11,19 +11,19 @@ from .blending import ( softmax_rgb_blend, ) from .camera_utils import join_cameras_as_batch, rotate_on_spot -from .cameras import OpenGLOrthographicCameras # deprecated -from .cameras import OpenGLPerspectiveCameras # deprecated -from .cameras import SfMOrthographicCameras # deprecated -from .cameras import SfMPerspectiveCameras # deprecated -from .cameras import ( +from .cameras import ( # deprecated # deprecated # deprecated # deprecated + camera_position_from_spherical_angles, FoVOrthographicCameras, FoVPerspectiveCameras, - OrthographicCameras, - PerspectiveCameras, - camera_position_from_spherical_angles, get_world_to_view_transform, look_at_rotation, look_at_view_transform, + OpenGLOrthographicCameras, + OpenGLPerspectiveCameras, + OrthographicCameras, + PerspectiveCameras, + SfMOrthographicCameras, + SfMPerspectiveCameras, ) from .implicit import ( AbsorptionOnlyRaymarcher, @@ -35,22 +35,25 @@ from .implicit import ( MultinomialRaysampler, NDCGridRaysampler, NDCMultinomialRaysampler, + ray_bundle_to_ray_points, + ray_bundle_variables_to_ray_points, RayBundle, VolumeRenderer, VolumeSampler, - ray_bundle_to_ray_points, - ray_bundle_variables_to_ray_points, ) -from .lighting import AmbientLights, DirectionalLights, PointLights, diffuse, specular +from .lighting import AmbientLights, diffuse, DirectionalLights, PointLights, specular from .materials import Materials from .mesh import ( + gouraud_shading, HardFlatShader, HardGouraudShader, HardPhongShader, MeshRasterizer, MeshRenderer, MeshRendererWithFragments, + phong_shading, RasterizationSettings, + rasterize_meshes, SoftGouraudShader, SoftPhongShader, SoftSilhouetteShader, @@ -58,9 +61,6 @@ from .mesh import ( TexturesAtlas, TexturesUV, TexturesVertex, - gouraud_shading, - phong_shading, - rasterize_meshes, ) from .points import ( AlphaCompositor, @@ -72,10 +72,10 @@ from .points import ( rasterize_points, ) from .utils import ( - TensorProperties, convert_to_tensors_and_broadcast, ndc_grid_sample, ndc_to_grid_sample_coords, + TensorProperties, ) diff --git a/pytorch3d/renderer/implicit/__init__.py b/pytorch3d/renderer/implicit/__init__.py index f3ec515e..bb617df8 100644 --- a/pytorch3d/renderer/implicit/__init__.py +++ b/pytorch3d/renderer/implicit/__init__.py @@ -15,9 +15,9 @@ from .raysampling import ( ) from .renderer import ImplicitRenderer, VolumeRenderer, VolumeSampler from .utils import ( - RayBundle, ray_bundle_to_ray_points, ray_bundle_variables_to_ray_points, + RayBundle, ) diff --git a/pytorch3d/renderer/lighting.py b/pytorch3d/renderer/lighting.py index 76fbe3a7..3ca81ca7 100644 --- a/pytorch3d/renderer/lighting.py +++ b/pytorch3d/renderer/lighting.py @@ -9,7 +9,7 @@ import torch import torch.nn.functional as F from ..common.datatypes import Device -from .utils import TensorProperties, convert_to_tensors_and_broadcast +from .utils import convert_to_tensors_and_broadcast, TensorProperties def diffuse(normals, color, direction) -> torch.Tensor: diff --git a/pytorch3d/renderer/mesh/__init__.py b/pytorch3d/renderer/mesh/__init__.py index ff28349e..e9e12cdc 100644 --- a/pytorch3d/renderer/mesh/__init__.py +++ b/pytorch3d/renderer/mesh/__init__.py @@ -6,16 +6,15 @@ from .clip import ( + clip_faces, ClipFrustum, ClippedFaces, - clip_faces, convert_clipped_rasterization_to_original_faces, ) from .rasterize_meshes import rasterize_meshes from .rasterizer import MeshRasterizer, RasterizationSettings from .renderer import MeshRenderer, MeshRendererWithFragments -from .shader import TexturedSoftPhongShader # DEPRECATED -from .shader import ( +from .shader import ( # DEPRECATED BlendParams, HardFlatShader, HardGouraudShader, @@ -23,10 +22,16 @@ from .shader import ( SoftGouraudShader, SoftPhongShader, SoftSilhouetteShader, + TexturedSoftPhongShader, ) from .shading import gouraud_shading, phong_shading -from .textures import Textures # DEPRECATED -from .textures import TexturesAtlas, TexturesBase, TexturesUV, TexturesVertex +from .textures import ( # DEPRECATED + Textures, + TexturesAtlas, + TexturesBase, + TexturesUV, + TexturesVertex, +) __all__ = [k for k in globals().keys() if not k.startswith("_")] diff --git a/pytorch3d/renderer/mesh/rasterize_meshes.py b/pytorch3d/renderer/mesh/rasterize_meshes.py index c0f9f397..68fb3ed5 100644 --- a/pytorch3d/renderer/mesh/rasterize_meshes.py +++ b/pytorch3d/renderer/mesh/rasterize_meshes.py @@ -12,8 +12,8 @@ import torch from pytorch3d import _C from .clip import ( - ClipFrustum, clip_faces, + ClipFrustum, convert_clipped_rasterization_to_original_faces, ) diff --git a/pytorch3d/structures/__init__.py b/pytorch3d/structures/__init__.py index 859ef54b..37986ad7 100644 --- a/pytorch3d/structures/__init__.py +++ b/pytorch3d/structures/__init__.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from .meshes import Meshes, join_meshes_as_batch, join_meshes_as_scene +from .meshes import join_meshes_as_batch, join_meshes_as_scene, Meshes from .pointclouds import Pointclouds from .utils import list_to_packed, list_to_padded, packed_to_list, padded_to_list from .volumes import Volumes diff --git a/pytorch3d/vis/plotly_vis.py b/pytorch3d/vis/plotly_vis.py index f0e438ec..b6e33e0c 100644 --- a/pytorch3d/vis/plotly_vis.py +++ b/pytorch3d/vis/plotly_vis.py @@ -11,14 +11,14 @@ import plotly.graph_objects as go import torch from plotly.subplots import make_subplots from pytorch3d.renderer import ( + ray_bundle_to_ray_points, RayBundle, TexturesAtlas, TexturesVertex, - ray_bundle_to_ray_points, ) from pytorch3d.renderer.camera_utils import camera_to_eye_at_up from pytorch3d.renderer.cameras import CamerasBase -from pytorch3d.structures import Meshes, Pointclouds, join_meshes_as_scene +from pytorch3d.structures import join_meshes_as_scene, Meshes, Pointclouds Struct = Union[CamerasBase, Meshes, Pointclouds, RayBundle] diff --git a/setup.py b/setup.py index 87902b57..f15bb70f 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from typing import List, Optional import torch from setuptools import find_packages, setup -from torch.utils.cpp_extension import CUDA_HOME, CppExtension, CUDAExtension +from torch.utils.cpp_extension import CppExtension, CUDA_HOME, CUDAExtension def get_existing_ccbin(nvcc_args: List[str]) -> Optional[str]: diff --git a/tests/implicitron/test_config.py b/tests/implicitron/test_config.py index 2be4595f..7076c656 100644 --- a/tests/implicitron/test_config.py +++ b/tests/implicitron/test_config.py @@ -13,18 +13,18 @@ from typing import Any, List, Optional, Set, Tuple from omegaconf import DictConfig, ListConfig, OmegaConf, ValidationError from pytorch3d.implicitron.tools.config import ( - Configurable, - ReplaceableBase, _get_type_to_process, _is_actually_dataclass, _ProcessType, _Registry, + Configurable, enable_get_default_args, expand_args_fields, get_default_args, get_default_args_field, registry, remove_unused_components, + ReplaceableBase, run_auto_creation, ) diff --git a/tests/implicitron/test_eval_cameras.py b/tests/implicitron/test_eval_cameras.py index 6ef3aa43..e4e014b3 100644 --- a/tests/implicitron/test_eval_cameras.py +++ b/tests/implicitron/test_eval_cameras.py @@ -11,7 +11,7 @@ import torch from pytorch3d.implicitron.tools.eval_video_trajectory import ( generate_eval_video_cameras, ) -from pytorch3d.renderer.cameras import PerspectiveCameras, look_at_view_transform +from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras from pytorch3d.transforms import axis_angle_to_matrix diff --git a/tests/implicitron/test_forward_pass.py b/tests/implicitron/test_forward_pass.py index eda733d6..c7406a6b 100644 --- a/tests/implicitron/test_forward_pass.py +++ b/tests/implicitron/test_forward_pass.py @@ -10,7 +10,7 @@ import torch from pytorch3d.implicitron.models.base import GenericModel from pytorch3d.implicitron.models.renderer.base import EvaluationMode from pytorch3d.implicitron.tools.config import expand_args_fields -from pytorch3d.renderer.cameras import PerspectiveCameras, look_at_view_transform +from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras class TestGenericModel(unittest.TestCase): diff --git a/tests/test_ball_query.py b/tests/test_ball_query.py index 202e08ad..0f58a191 100644 --- a/tests/test_ball_query.py +++ b/tests/test_ball_query.py @@ -8,7 +8,7 @@ import unittest from itertools import product import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import sample_points_from_meshes from pytorch3d.ops.ball_query import ball_query from pytorch3d.ops.knn import _KNN diff --git a/tests/test_camera_conversions.py b/tests/test_camera_conversions.py index 47c26665..15017a25 100644 --- a/tests/test_camera_conversions.py +++ b/tests/test_camera_conversions.py @@ -10,7 +10,7 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_tests_dir +from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops import eyes from pytorch3d.renderer.points.pulsar import Renderer as PulsarRenderer from pytorch3d.transforms import so3_exp_map, so3_log_map diff --git a/tests/test_camera_utils.py b/tests/test_camera_utils.py index e8638ebd..32d87c2a 100644 --- a/tests/test_camera_utils.py +++ b/tests/test_camera_utils.py @@ -11,9 +11,9 @@ import torch from common_testing import TestCaseMixin from pytorch3d.renderer.camera_utils import camera_to_eye_at_up, rotate_on_spot from pytorch3d.renderer.cameras import ( - PerspectiveCameras, get_world_to_view_transform, look_at_view_transform, + PerspectiveCameras, ) from pytorch3d.transforms import axis_angle_to_matrix from torch.nn.functional import normalize diff --git a/tests/test_cameras.py b/tests/test_cameras.py index f2cb14b5..d3da872f 100644 --- a/tests/test_cameras.py +++ b/tests/test_cameras.py @@ -39,19 +39,19 @@ import torch from common_testing import TestCaseMixin from pytorch3d.renderer.camera_utils import join_cameras_as_batch from pytorch3d.renderer.cameras import ( + camera_position_from_spherical_angles, CamerasBase, FoVOrthographicCameras, FoVPerspectiveCameras, + get_world_to_view_transform, + look_at_rotation, + look_at_view_transform, OpenGLOrthographicCameras, OpenGLPerspectiveCameras, OrthographicCameras, PerspectiveCameras, SfMOrthographicCameras, SfMPerspectiveCameras, - camera_position_from_spherical_angles, - get_world_to_view_transform, - look_at_rotation, - look_at_view_transform, ) from pytorch3d.transforms import Transform3d from pytorch3d.transforms.rotation_conversions import random_rotations diff --git a/tests/test_chamfer.py b/tests/test_chamfer.py index 0231f41f..55efe36e 100644 --- a/tests/test_chamfer.py +++ b/tests/test_chamfer.py @@ -10,7 +10,7 @@ from collections import namedtuple import numpy as np import torch import torch.nn.functional as F -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.loss import chamfer_distance from pytorch3d.structures.pointclouds import Pointclouds diff --git a/tests/test_compositing.py b/tests/test_compositing.py index 60828dd7..1d474da2 100644 --- a/tests/test_compositing.py +++ b/tests/test_compositing.py @@ -7,7 +7,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.renderer.compositing import ( alpha_composite, norm_weighted_sum, diff --git a/tests/test_face_areas_normals.py b/tests/test_face_areas_normals.py index 7fa22151..0b3b0fdc 100644 --- a/tests/test_face_areas_normals.py +++ b/tests/test_face_areas_normals.py @@ -8,7 +8,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import mesh_face_areas_normals from pytorch3d.structures.meshes import Meshes diff --git a/tests/test_graph_conv.py b/tests/test_graph_conv.py index d853c66a..c4c16d60 100644 --- a/tests/test_graph_conv.py +++ b/tests/test_graph_conv.py @@ -8,9 +8,9 @@ import unittest import torch import torch.nn as nn -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C -from pytorch3d.ops.graph_conv import GraphConv, gather_scatter, gather_scatter_python +from pytorch3d.ops.graph_conv import gather_scatter, gather_scatter_python, GraphConv from pytorch3d.structures.meshes import Meshes from pytorch3d.utils import ico_sphere diff --git a/tests/test_interpolate_face_attributes.py b/tests/test_interpolate_face_attributes.py index 17b1ec06..dc67e9a1 100644 --- a/tests/test_interpolate_face_attributes.py +++ b/tests/test_interpolate_face_attributes.py @@ -7,7 +7,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops.interp_face_attrs import ( interpolate_face_attributes, interpolate_face_attributes_python, diff --git a/tests/test_io_gltf.py b/tests/test_io_gltf.py index c6528507..d1fa34a0 100644 --- a/tests/test_io_gltf.py +++ b/tests/test_io_gltf.py @@ -9,7 +9,7 @@ from math import radians import numpy as np import torch -from common_testing import TestCaseMixin, get_pytorch3d_dir, get_tests_dir +from common_testing import get_pytorch3d_dir, get_tests_dir, TestCaseMixin from PIL import Image from pytorch3d.io import IO from pytorch3d.io.experimental_gltf_io import MeshGlbFormat @@ -17,9 +17,9 @@ from pytorch3d.renderer import ( AmbientLights, BlendParams, FoVPerspectiveCameras, + look_at_view_transform, PointLights, RasterizationSettings, - look_at_view_transform, rotate_on_spot, ) from pytorch3d.renderer.mesh import ( diff --git a/tests/test_io_obj.py b/tests/test_io_obj.py index 0d9e54f8..c47a58ad 100644 --- a/tests/test_io_obj.py +++ b/tests/test_io_obj.py @@ -14,10 +14,10 @@ from tempfile import NamedTemporaryFile, TemporaryDirectory import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_tests_dir, load_rgb_image, + TestCaseMixin, ) from iopath.common.file_io import PathManager from pytorch3d.io import IO, load_obj, load_objs_as_meshes, save_obj @@ -27,7 +27,7 @@ from pytorch3d.io.mtl_io import ( _parse_mtl, ) from pytorch3d.renderer import TexturesAtlas, TexturesUV, TexturesVertex -from pytorch3d.structures import Meshes, join_meshes_as_batch +from pytorch3d.structures import join_meshes_as_batch, Meshes from pytorch3d.utils import torus diff --git a/tests/test_iou_box3d.py b/tests/test_iou_box3d.py index b934f576..bd25d3cd 100644 --- a/tests/test_iou_box3d.py +++ b/tests/test_iou_box3d.py @@ -11,7 +11,7 @@ from typing import List, Tuple, Union import torch import torch.nn.functional as F -from common_testing import TestCaseMixin, get_random_cuda_device, get_tests_dir +from common_testing import get_random_cuda_device, get_tests_dir, TestCaseMixin from pytorch3d.io import save_obj from pytorch3d.ops.iou_box3d import _box_planes, _box_triangles, box3d_overlap from pytorch3d.transforms.rotation_conversions import random_rotation diff --git a/tests/test_knn.py b/tests/test_knn.py index 6318ff0c..d3c56681 100644 --- a/tests/test_knn.py +++ b/tests/test_knn.py @@ -8,7 +8,7 @@ import unittest from itertools import product import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops.knn import _KNN, knn_gather, knn_points diff --git a/tests/test_laplacian_matrices.py b/tests/test_laplacian_matrices.py index d64b021a..088efdf1 100644 --- a/tests/test_laplacian_matrices.py +++ b/tests/test_laplacian_matrices.py @@ -7,7 +7,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import cot_laplacian, laplacian, norm_laplacian from pytorch3d.structures.meshes import Meshes diff --git a/tests/test_marching_cubes.py b/tests/test_marching_cubes.py index b979049a..2b8370f4 100644 --- a/tests/test_marching_cubes.py +++ b/tests/test_marching_cubes.py @@ -9,7 +9,7 @@ import pickle import unittest import torch -from common_testing import TestCaseMixin, get_tests_dir +from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops.marching_cubes import marching_cubes_naive diff --git a/tests/test_mesh_filtering.py b/tests/test_mesh_filtering.py index 91fecc29..285d89e5 100644 --- a/tests/test_mesh_filtering.py +++ b/tests/test_mesh_filtering.py @@ -8,7 +8,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import taubin_smoothing from pytorch3d.structures import Meshes from pytorch3d.utils import ico_sphere diff --git a/tests/test_packed_to_padded.py b/tests/test_packed_to_padded.py index b5b469e5..6114366e 100644 --- a/tests/test_packed_to_padded.py +++ b/tests/test_packed_to_padded.py @@ -7,7 +7,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import packed_to_padded, padded_to_packed from pytorch3d.structures.meshes import Meshes diff --git a/tests/test_point_mesh_distance.py b/tests/test_point_mesh_distance.py index 2281d1fd..cf26c159 100644 --- a/tests/test_point_mesh_distance.py +++ b/tests/test_point_mesh_distance.py @@ -8,10 +8,10 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.loss import point_mesh_edge_distance, point_mesh_face_distance -from pytorch3d.structures import Meshes, Pointclouds, packed_to_list +from pytorch3d.structures import Meshes, packed_to_list, Pointclouds class TestPointMeshDistance(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_pointclouds.py b/tests/test_pointclouds.py index 52efee18..b2780681 100644 --- a/tests/test_pointclouds.py +++ b/tests/test_pointclouds.py @@ -12,7 +12,7 @@ import numpy as np import torch from common_testing import TestCaseMixin from pytorch3d.structures import utils as struct_utils -from pytorch3d.structures.pointclouds import Pointclouds, join_pointclouds_as_batch +from pytorch3d.structures.pointclouds import join_pointclouds_as_batch, Pointclouds class TestPointclouds(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_points_alignment.py b/tests/test_points_alignment.py index c6f50400..25c43be8 100644 --- a/tests/test_points_alignment.py +++ b/tests/test_points_alignment.py @@ -8,7 +8,7 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_tests_dir +from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops import points_alignment from pytorch3d.structures.pointclouds import Pointclouds from pytorch3d.transforms import rotation_conversions diff --git a/tests/test_r2n2.py b/tests/test_r2n2.py index 46dd6e03..5b1308d1 100644 --- a/tests/test_r2n2.py +++ b/tests/test_r2n2.py @@ -13,19 +13,19 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_tests_dir, load_rgb_image +from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from PIL import Image from pytorch3d.datasets import ( - R2N2, BlenderCamera, collate_batched_R2N2, + R2N2, render_cubified_voxels, ) from pytorch3d.renderer import ( FoVPerspectiveCameras, + look_at_view_transform, PointLights, RasterizationSettings, - look_at_view_transform, ) from pytorch3d.renderer.cameras import get_world_to_view_transform from pytorch3d.transforms import Transform3d diff --git a/tests/test_rasterize_meshes.py b/tests/test_rasterize_meshes.py index a5094fc7..8fada036 100644 --- a/tests/test_rasterize_meshes.py +++ b/tests/test_rasterize_meshes.py @@ -8,7 +8,7 @@ import functools import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.renderer import FoVPerspectiveCameras, look_at_view_transform from pytorch3d.renderer.mesh import MeshRasterizer, RasterizationSettings diff --git a/tests/test_rasterize_points.py b/tests/test_rasterize_points.py index 01ffd64d..09d4632e 100644 --- a/tests/test_rasterize_points.py +++ b/tests/test_rasterize_points.py @@ -9,7 +9,7 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.renderer.points.rasterize_points import ( _format_radius, diff --git a/tests/test_rasterize_rectangle_images.py b/tests/test_rasterize_rectangle_images.py index d57f6044..c67ae865 100644 --- a/tests/test_rasterize_rectangle_images.py +++ b/tests/test_rasterize_rectangle_images.py @@ -10,10 +10,10 @@ from itertools import product import numpy as np import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_tests_dir, load_rgb_image, + TestCaseMixin, ) from PIL import Image from pytorch3d.io import load_obj diff --git a/tests/test_render_implicit.py b/tests/test_render_implicit.py index 60ca2d23..62d6ee8c 100644 --- a/tests/test_render_implicit.py +++ b/tests/test_render_implicit.py @@ -21,10 +21,10 @@ from pytorch3d.renderer import ( NDCMultinomialRaysampler, PointLights, RasterizationSettings, + ray_bundle_to_ray_points, RayBundle, SoftPhongShader, TexturesVertex, - ray_bundle_to_ray_points, ) from pytorch3d.structures import Meshes from pytorch3d.utils import ico_sphere diff --git a/tests/test_render_meshes.py b/tests/test_render_meshes.py index ff6c8bf4..5b033831 100644 --- a/tests/test_render_meshes.py +++ b/tests/test_render_meshes.py @@ -15,19 +15,19 @@ from collections import namedtuple import numpy as np import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_tests_dir, load_rgb_image, + TestCaseMixin, ) from PIL import Image from pytorch3d.io import load_obj from pytorch3d.renderer.cameras import ( FoVOrthographicCameras, FoVPerspectiveCameras, + look_at_view_transform, OrthographicCameras, PerspectiveCameras, - look_at_view_transform, ) from pytorch3d.renderer.lighting import AmbientLights, PointLights from pytorch3d.renderer.materials import Materials @@ -44,9 +44,9 @@ from pytorch3d.renderer.mesh.shader import ( TexturedSoftPhongShader, ) from pytorch3d.structures.meshes import ( - Meshes, join_meshes_as_batch, join_meshes_as_scene, + Meshes, ) from pytorch3d.utils.ico_sphere import ico_sphere from pytorch3d.utils.torus import torus diff --git a/tests/test_render_meshes_clipped.py b/tests/test_render_meshes_clipped.py index 75d35dde..68954ac5 100644 --- a/tests/test_render_meshes_clipped.py +++ b/tests/test_render_meshes_clipped.py @@ -17,19 +17,19 @@ import unittest import imageio import numpy as np import torch -from common_testing import TestCaseMixin, get_tests_dir, load_rgb_image +from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from pytorch3d.io import save_obj from pytorch3d.renderer.cameras import ( FoVPerspectiveCameras, - PerspectiveCameras, look_at_view_transform, + PerspectiveCameras, ) from pytorch3d.renderer.lighting import PointLights from pytorch3d.renderer.mesh import ( - ClipFrustum, - TexturesUV, clip_faces, + ClipFrustum, convert_clipped_rasterization_to_original_faces, + TexturesUV, ) from pytorch3d.renderer.mesh.rasterize_meshes import _RasterizeFaceVerts from pytorch3d.renderer.mesh.rasterizer import MeshRasterizer, RasterizationSettings diff --git a/tests/test_render_multigpu.py b/tests/test_render_multigpu.py index 2e62dd61..161101c8 100644 --- a/tests/test_render_multigpu.py +++ b/tests/test_render_multigpu.py @@ -8,7 +8,7 @@ import unittest import torch import torch.nn as nn -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.renderer import ( AlphaCompositor, BlendParams, diff --git a/tests/test_render_points.py b/tests/test_render_points.py index f2ff9bb3..7278b7c9 100644 --- a/tests/test_render_points.py +++ b/tests/test_render_points.py @@ -15,18 +15,18 @@ from os import path import numpy as np import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_tests_dir, load_rgb_image, + TestCaseMixin, ) from PIL import Image from pytorch3d.renderer.cameras import ( FoVOrthographicCameras, FoVPerspectiveCameras, + look_at_view_transform, OrthographicCameras, PerspectiveCameras, - look_at_view_transform, ) from pytorch3d.renderer.compositing import alpha_composite, norm_weighted_sum from pytorch3d.renderer.points import ( diff --git a/tests/test_rendering_utils.py b/tests/test_rendering_utils.py index 3a7c668d..a62fc891 100644 --- a/tests/test_rendering_utils.py +++ b/tests/test_rendering_utils.py @@ -20,9 +20,9 @@ from pytorch3d.renderer import ( PointsRenderer, ) from pytorch3d.renderer.utils import ( - TensorProperties, ndc_grid_sample, ndc_to_grid_sample_coords, + TensorProperties, ) from pytorch3d.structures import Pointclouds diff --git a/tests/test_sample_farthest_points.py b/tests/test_sample_farthest_points.py index f5348d48..75ec389c 100644 --- a/tests/test_sample_farthest_points.py +++ b/tests/test_sample_farthest_points.py @@ -9,10 +9,10 @@ import unittest import numpy as np import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_random_cuda_device, get_tests_dir, + TestCaseMixin, ) from pytorch3d.io import load_obj from pytorch3d.ops.sample_farthest_points import ( diff --git a/tests/test_sample_points_from_meshes.py b/tests/test_sample_points_from_meshes.py index 4069cb37..c0f3bddd 100644 --- a/tests/test_sample_points_from_meshes.py +++ b/tests/test_sample_points_from_meshes.py @@ -10,10 +10,10 @@ import unittest import numpy as np import torch from common_testing import ( - TestCaseMixin, get_pytorch3d_dir, get_random_cuda_device, get_tests_dir, + TestCaseMixin, ) from PIL import Image from pytorch3d.io import load_objs_as_meshes diff --git a/tests/test_shader.py b/tests/test_shader.py index 1712dacb..5512f6e2 100644 --- a/tests/test_shader.py +++ b/tests/test_shader.py @@ -8,7 +8,7 @@ import unittest import torch from common_testing import TestCaseMixin -from pytorch3d.renderer.cameras import PerspectiveCameras, look_at_view_transform +from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.renderer.mesh.shader import ( HardFlatShader, diff --git a/tests/test_shapenet_core.py b/tests/test_shapenet_core.py index ce8dfa57..bc658266 100644 --- a/tests/test_shapenet_core.py +++ b/tests/test_shapenet_core.py @@ -12,14 +12,14 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin, get_tests_dir, load_rgb_image +from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from PIL import Image -from pytorch3d.datasets import ShapeNetCore, collate_batched_meshes +from pytorch3d.datasets import collate_batched_meshes, ShapeNetCore from pytorch3d.renderer import ( FoVPerspectiveCameras, + look_at_view_transform, PointLights, RasterizationSettings, - look_at_view_transform, ) from torch.utils.data import DataLoader diff --git a/tests/test_symeig3x3.py b/tests/test_symeig3x3.py index 283d5278..f8f5e445 100644 --- a/tests/test_symeig3x3.py +++ b/tests/test_symeig3x3.py @@ -8,7 +8,7 @@ import unittest import torch -from common_testing import TestCaseMixin, get_random_cuda_device +from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.common.workaround import symeig3x3 from pytorch3d.transforms.rotation_conversions import random_rotations