diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index acfebeb5..03de8213 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -368,7 +368,7 @@ def _load_obj( # startswith expects each line to be a string. If the file is read in as # bytes then first decode to strings. if lines and isinstance(lines[0], bytes): - lines = [l.decode("utf-8") for l in lines] + lines = [el.decode("utf-8") for el in lines] for line in lines: if line.startswith("mtllib"): diff --git a/pytorch3d/renderer/compositing.py b/pytorch3d/renderer/compositing.py index 3379deaf..c04da4d6 100644 --- a/pytorch3d/renderer/compositing.py +++ b/pytorch3d/renderer/compositing.py @@ -1,9 +1,5 @@ -#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. - -from typing import NamedTuple - import torch from pytorch3d import _C diff --git a/pytorch3d/renderer/mesh/rasterizer.py b/pytorch3d/renderer/mesh/rasterizer.py index eefe1cf4..ac0b7402 100644 --- a/pytorch3d/renderer/mesh/rasterizer.py +++ b/pytorch3d/renderer/mesh/rasterizer.py @@ -5,7 +5,6 @@ from typing import NamedTuple, Optional import torch import torch.nn as nn -from ..cameras import get_world_to_view_transform from .rasterize_meshes import rasterize_meshes diff --git a/pytorch3d/renderer/mesh/renderer.py b/pytorch3d/renderer/mesh/renderer.py index 46c0231f..8e5789bb 100644 --- a/pytorch3d/renderer/mesh/renderer.py +++ b/pytorch3d/renderer/mesh/renderer.py @@ -4,9 +4,6 @@ import torch import torch.nn as nn -from .rasterizer import Fragments -from .utils import _clip_barycentric_coordinates, _interpolate_zbuf - # A renderer class should be initialized with a # function for rasterization and a function for shading. diff --git a/pytorch3d/renderer/points/rasterizer.py b/pytorch3d/renderer/points/rasterizer.py index 91fad704..8b6d8f1f 100644 --- a/pytorch3d/renderer/points/rasterizer.py +++ b/pytorch3d/renderer/points/rasterizer.py @@ -7,7 +7,6 @@ from typing import NamedTuple, Optional import torch import torch.nn as nn -from ..cameras import get_world_to_view_transform from .rasterize_points import rasterize_points diff --git a/pytorch3d/transforms/transform3d.py b/pytorch3d/transforms/transform3d.py index ac061cbc..b3bc2f44 100644 --- a/pytorch3d/transforms/transform3d.py +++ b/pytorch3d/transforms/transform3d.py @@ -375,7 +375,7 @@ class Transform3d: """ other = Transform3d(device=self.device) if self._lu is not None: - other._lu = [l.clone() for l in self._lu] + other._lu = [elem.clone() for elem in self._lu] other._matrix = self._matrix.clone() other._transforms = [t.clone() for t in self._transforms] return other diff --git a/tests/test_interpolate_face_attributes.py b/tests/test_interpolate_face_attributes.py index 7eaf9ef9..e943f3ff 100644 --- a/tests/test_interpolate_face_attributes.py +++ b/tests/test_interpolate_face_attributes.py @@ -9,10 +9,7 @@ from pytorch3d.ops.interp_face_attrs import ( interpolate_face_attributes_python, ) from pytorch3d.renderer.mesh.rasterizer import Fragments -from pytorch3d.renderer.mesh.texturing import ( - interpolate_texture_map, - interpolate_vertex_colors, -) +from pytorch3d.renderer.mesh.texturing import interpolate_vertex_colors from pytorch3d.structures import Meshes, Textures diff --git a/tests/test_rasterize_meshes.py b/tests/test_rasterize_meshes.py index c6746ccf..e25b5c8c 100644 --- a/tests/test_rasterize_meshes.py +++ b/tests/test_rasterize_meshes.py @@ -571,9 +571,9 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase): def _test_perspective_correct(self, rasterize_meshes_fn, device, bin_size=None): # fmt: off verts = torch.tensor([ - [-0.4, -0.4, 10], # noqa: E241, E201 - [ 0.4, -0.4, 10], # noqa: E241, E201 - [ 0.0, 0.4, 20], # noqa: E241, E201 + [-0.4, -0.4, 10], # noqa: E241, E201 + [ 0.4, -0.4, 10], # noqa: E241, E201 + [ 0.0, 0.4, 20], # noqa: E241, E201 ], dtype=torch.float32, device=device) # fmt: on faces = torch.tensor([[0, 1, 2]], device=device) @@ -641,17 +641,17 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase): ], dtype=torch.float32, device=device).view(1, 11, 11, 1) zbuf_t_expected = torch.tensor([ - [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], # noqa: E241, E201 - [-1., -1., -1., -1., 33.8461, 33.8462, 33.8462, -1., -1., -1., -1.], # noqa: E241, E201 - [-1., -1., -1., 24.4444, 24.4444, 24.4444, 24.4444, 24.4444, -1., -1., -1.], # noqa: E241, E201 - [-1., -1., -1., 19.1304, 19.1304, 19.1304, 19.1304, 19.1304, -1., -1., -1.], # noqa: E241, E201 - [-1., -1., 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, -1., -1.], # noqa: E241, E201 - [-1., -1., 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, -1., -1.], # noqa: E241, E201 - [-1., 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, -1.], # noqa: E241, E201 - [-1., 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, -1.], # noqa: E241, E201 - [-1., 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, -1.], # noqa: E241, E201 - [-1., -1., 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, -1., -1.], # noqa: E241, E201 - [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.] # noqa: E241, E201 + [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], # noqa: E241, E201 + [-1., -1., -1., -1., 33.8461, 33.8462, 33.8462, -1., -1., -1., -1.], # noqa: E241, E201 + [-1., -1., -1., 24.4444, 24.4444, 24.4444, 24.4444, 24.4444, -1., -1., -1.], # noqa: E241, E201 + [-1., -1., -1., 19.1304, 19.1304, 19.1304, 19.1304, 19.1304, -1., -1., -1.], # noqa: E241, E201 + [-1., -1., 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, 15.7143, -1., -1.], # noqa: E241, E201 + [-1., -1., 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, -1., -1.], # noqa: E241, E201 + [-1., 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, 11.5789, -1.], # noqa: E241, E201 + [-1., 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, 10.2326, -1.], # noqa: E241, E201 + [-1., 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, 9.1667, -1.], # noqa: E241, E201 + [-1., -1., 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, 8.3019, -1., -1.], # noqa: E241, E201 + [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.] # noqa: E241, E201 ], dtype=torch.float32, device=device).view(1, 11, 11, 1) # fmt: on @@ -890,32 +890,32 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase): device=device, ) expected_zbuf_k0 = torch.tensor( - [ [ - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, 0.1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, 0.1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, 0.1, 0.1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 + [ + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, 0.1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, 0.1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, 0.1, 0.1, 0.1, 0.1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 + ], + [ + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, 0.5, 0.5, 0.1, 0.1, 0.1, 0.5, -1, -1], # noqa: E241, E201 + [-1, -1, -1, 0.1, 0.1, 0.1, 0.1, 0.1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1], # noqa: E241, E201 + [-1, -1, 0.1, 0.1, 0.1, 0.5, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 + ] ], - [ - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, 0.1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, 0.5, 0.5, 0.1, 0.1, 0.1, 0.5, -1, -1], # noqa: E241, E201 - [-1, -1, -1, 0.1, 0.1, 0.1, 0.1, 0.1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1], # noqa: E241, E201 - [-1, -1, 0.1, 0.1, 0.1, 0.5, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 - ] - ], device=device, ) # fmt: on @@ -928,18 +928,18 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase): # fmt: off expected_p2face_k1[1, :] = torch.tensor( - [ - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, 2, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, 2, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, 2, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 - ], + [ + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, 2, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, 2, 2, 2, 2, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, 2, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # noqa: E241, E201 + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] # noqa: E241, E201 + ], dtype=torch.int64, device=device, )