mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 20:02:49 +08:00
pyre and lint fixes
Summary: Fixing several unused imports and pyre/linter warnings. Reviewed By: bottler Differential Revision: D22592491 fbshipit-source-id: 463383b9b73a545949475044fb5c531712f8482c
This commit is contained in:
parent
7e5bad475c
commit
4f78af6170
@ -368,7 +368,7 @@ def _load_obj(
|
|||||||
# startswith expects each line to be a string. If the file is read in as
|
# startswith expects each line to be a string. If the file is read in as
|
||||||
# bytes then first decode to strings.
|
# bytes then first decode to strings.
|
||||||
if lines and isinstance(lines[0], bytes):
|
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:
|
for line in lines:
|
||||||
if line.startswith("mtllib"):
|
if line.startswith("mtllib"):
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
from typing import NamedTuple
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from pytorch3d import _C
|
from pytorch3d import _C
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ from typing import NamedTuple, Optional
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from ..cameras import get_world_to_view_transform
|
|
||||||
from .rasterize_meshes import rasterize_meshes
|
from .rasterize_meshes import rasterize_meshes
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
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
|
# A renderer class should be initialized with a
|
||||||
# function for rasterization and a function for shading.
|
# function for rasterization and a function for shading.
|
||||||
|
@ -7,7 +7,6 @@ from typing import NamedTuple, Optional
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from ..cameras import get_world_to_view_transform
|
|
||||||
from .rasterize_points import rasterize_points
|
from .rasterize_points import rasterize_points
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class Transform3d:
|
|||||||
"""
|
"""
|
||||||
other = Transform3d(device=self.device)
|
other = Transform3d(device=self.device)
|
||||||
if self._lu is not None:
|
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._matrix = self._matrix.clone()
|
||||||
other._transforms = [t.clone() for t in self._transforms]
|
other._transforms = [t.clone() for t in self._transforms]
|
||||||
return other
|
return other
|
||||||
|
@ -9,10 +9,7 @@ from pytorch3d.ops.interp_face_attrs import (
|
|||||||
interpolate_face_attributes_python,
|
interpolate_face_attributes_python,
|
||||||
)
|
)
|
||||||
from pytorch3d.renderer.mesh.rasterizer import Fragments
|
from pytorch3d.renderer.mesh.rasterizer import Fragments
|
||||||
from pytorch3d.renderer.mesh.texturing import (
|
from pytorch3d.renderer.mesh.texturing import interpolate_vertex_colors
|
||||||
interpolate_texture_map,
|
|
||||||
interpolate_vertex_colors,
|
|
||||||
)
|
|
||||||
from pytorch3d.structures import Meshes, Textures
|
from pytorch3d.structures import Meshes, Textures
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,9 +571,9 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
|||||||
def _test_perspective_correct(self, rasterize_meshes_fn, device, bin_size=None):
|
def _test_perspective_correct(self, rasterize_meshes_fn, device, bin_size=None):
|
||||||
# fmt: off
|
# fmt: off
|
||||||
verts = torch.tensor([
|
verts = torch.tensor([
|
||||||
[-0.4, -0.4, 10], # noqa: E241, E201
|
[-0.4, -0.4, 10], # 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
|
[ 0.0, 0.4, 20], # noqa: E241, E201
|
||||||
], dtype=torch.float32, device=device)
|
], dtype=torch.float32, device=device)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
faces = torch.tensor([[0, 1, 2]], device=device)
|
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)
|
], dtype=torch.float32, device=device).view(1, 11, 11, 1)
|
||||||
|
|
||||||
zbuf_t_expected = torch.tensor([
|
zbuf_t_expected = torch.tensor([
|
||||||
[-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., -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., 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., -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., 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., -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., 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., 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., 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., 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
|
||||||
], dtype=torch.float32, device=device).view(1, 11, 11, 1)
|
], dtype=torch.float32, device=device).view(1, 11, 11, 1)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
@ -890,32 +890,32 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
|||||||
device=device,
|
device=device,
|
||||||
)
|
)
|
||||||
expected_zbuf_k0 = torch.tensor(
|
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, -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, -1, -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, -1, -1, 0.1, -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, -1, -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, 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, 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, -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,
|
device=device,
|
||||||
)
|
)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
@ -928,18 +928,18 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
|||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
expected_p2face_k1[1, :] = torch.tensor(
|
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, -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, -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, 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, 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
|
||||||
],
|
],
|
||||||
dtype=torch.int64,
|
dtype=torch.int64,
|
||||||
device=device,
|
device=device,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user