mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 06:10:34 +08:00
apply Black 2024 style in fbcode (4/16)
Summary: Formats the covered files with pyfmt. paintitblack Reviewed By: aleivag Differential Revision: D54447727 fbshipit-source-id: 8844b1caa08de94d04ac4df3c768dbf8c865fd2f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f34104cf6e
commit
3da7703c5a
@@ -61,9 +61,9 @@ class ExtendedSqlFrameAnnotation(SqlFrameAnnotation):
|
||||
|
||||
|
||||
class ExtendedSqlIndexDataset(SqlIndexDataset):
|
||||
frame_annotations_type: ClassVar[
|
||||
Type[SqlFrameAnnotation]
|
||||
] = ExtendedSqlFrameAnnotation
|
||||
frame_annotations_type: ClassVar[Type[SqlFrameAnnotation]] = (
|
||||
ExtendedSqlFrameAnnotation
|
||||
)
|
||||
|
||||
|
||||
class CanineFrameData(FrameData):
|
||||
@@ -96,9 +96,9 @@ class CanineFrameDataBuilder(
|
||||
|
||||
|
||||
class CanineSqlIndexDataset(SqlIndexDataset):
|
||||
frame_annotations_type: ClassVar[
|
||||
Type[SqlFrameAnnotation]
|
||||
] = ExtendedSqlFrameAnnotation
|
||||
frame_annotations_type: ClassVar[Type[SqlFrameAnnotation]] = (
|
||||
ExtendedSqlFrameAnnotation
|
||||
)
|
||||
|
||||
frame_data_builder_class_type: str = "CanineFrameDataBuilder"
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ class TestFrameDataBuilder(TestCaseMixin, unittest.TestCase):
|
||||
camera_quality_score=safe_as_tensor(
|
||||
self.seq_annotation.viewpoint_quality_score, torch.float
|
||||
),
|
||||
point_cloud_quality_score=safe_as_tensor(
|
||||
point_cloud.quality_score, torch.float
|
||||
)
|
||||
if point_cloud is not None
|
||||
else None,
|
||||
point_cloud_quality_score=(
|
||||
safe_as_tensor(point_cloud.quality_score, torch.float)
|
||||
if point_cloud is not None
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
def test_frame_data_builder_args(self):
|
||||
|
||||
@@ -168,7 +168,10 @@ def _make_random_json_dataset_map_provider_v2_data(
|
||||
mask_path = os.path.join(maskdir, f"frame{i:05d}.png")
|
||||
mask = np.zeros((H, W))
|
||||
mask[H // 2 :, W // 2 :] = 1
|
||||
Image.fromarray((mask * 255.0).astype(np.uint8), mode="L",).convert(
|
||||
Image.fromarray(
|
||||
(mask * 255.0).astype(np.uint8),
|
||||
mode="L",
|
||||
).convert(
|
||||
"L"
|
||||
).save(mask_path)
|
||||
|
||||
|
||||
@@ -222,10 +222,7 @@ class TestRendererBase(TestCaseMixin, unittest.TestCase):
|
||||
np.testing.assert_allclose(
|
||||
(delta**2) / 3
|
||||
- (4 / 15)
|
||||
* (
|
||||
(delta**4 * (12 * mu**2 - delta**2))
|
||||
/ (3 * mu**2 + delta**2) ** 2
|
||||
),
|
||||
* ((delta**4 * (12 * mu**2 - delta**2)) / (3 * mu**2 + delta**2) ** 2),
|
||||
t_var.numpy(),
|
||||
)
|
||||
np.testing.assert_allclose(
|
||||
|
||||
@@ -983,7 +983,7 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
verts_list = []
|
||||
faces_list = []
|
||||
verts_faces = [(10, 100), (20, 200)]
|
||||
for (V, F) in verts_faces:
|
||||
for V, F in verts_faces:
|
||||
verts = torch.rand((V, 3), dtype=torch.float32, device=device)
|
||||
faces = torch.randint(V, size=(F, 3), dtype=torch.int64, device=device)
|
||||
verts_list.append(verts)
|
||||
@@ -1007,7 +1007,7 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
device = torch.device("cuda:0")
|
||||
verts_list = []
|
||||
faces_list = []
|
||||
for (V, F) in [(10, 100)]:
|
||||
for V, F in [(10, 100)]:
|
||||
verts = torch.rand((V, 3), dtype=torch.float32, device=device)
|
||||
faces = torch.randint(V, size=(F, 3), dtype=torch.int64, device=device)
|
||||
verts_list.append(verts)
|
||||
@@ -1025,7 +1025,7 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
verts_list = []
|
||||
faces_list = []
|
||||
verts_faces = [(10, 100), (20, 200), (30, 300)]
|
||||
for (V, F) in verts_faces:
|
||||
for V, F in verts_faces:
|
||||
verts = torch.rand((V, 3), dtype=torch.float32, device=device)
|
||||
faces = torch.randint(V, size=(F, 3), dtype=torch.int64, device=device)
|
||||
verts_list.append(verts)
|
||||
@@ -1047,7 +1047,7 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
verts_list = []
|
||||
faces_list = []
|
||||
verts_faces = [(10, 100), (20, 200), (30, 300)]
|
||||
for (V, F) in verts_faces:
|
||||
for V, F in verts_faces:
|
||||
verts = torch.rand((V, 3), dtype=torch.float32, device=device)
|
||||
faces = torch.randint(V, size=(F, 3), dtype=torch.int64, device=device)
|
||||
verts_list.append(verts)
|
||||
|
||||
@@ -284,7 +284,7 @@ class TestRenderImplicit(TestCaseMixin, unittest.TestCase):
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
|
||||
frames = []
|
||||
for (image_opacity, image_opacity_mesh) in zip(
|
||||
for image_opacity, image_opacity_mesh in zip(
|
||||
images_opacities, images_opacities_meshes
|
||||
):
|
||||
image, opacity = image_opacity.split([3, 1], dim=-1)
|
||||
|
||||
@@ -303,7 +303,6 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self.test_simple_sphere(check_depth=True)
|
||||
|
||||
def test_simple_sphere_screen(self):
|
||||
|
||||
"""
|
||||
Test output when rendering with PerspectiveCameras & OrthographicCameras
|
||||
in NDC vs screen space.
|
||||
@@ -1221,7 +1220,7 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
"flat": HardFlatShader,
|
||||
"splatter": SplatterPhongShader,
|
||||
}
|
||||
for (name, shader_init) in shaders.items():
|
||||
for name, shader_init in shaders.items():
|
||||
if rasterizer_type == MeshRasterizerOpenGL and name != "splatter":
|
||||
continue
|
||||
if rasterizer_type == MeshRasterizer and name == "splatter":
|
||||
|
||||
@@ -620,7 +620,7 @@ class TestRenderMeshesClipping(TestCaseMixin, unittest.TestCase):
|
||||
plane into a quadrilateral, there shouldn't be duplicates indices of
|
||||
the face in the pix_to_face output of rasterization.
|
||||
"""
|
||||
for (device, bin_size) in [("cpu", 0), ("cuda:0", 0), ("cuda:0", None)]:
|
||||
for device, bin_size in [("cpu", 0), ("cuda:0", 0), ("cuda:0", None)]:
|
||||
verts = torch.tensor(
|
||||
[[0.0, -10.0, 1.0], [-1.0, 2.0, -2.0], [1.0, 5.0, -10.0]],
|
||||
dtype=torch.float32,
|
||||
@@ -673,7 +673,7 @@ class TestRenderMeshesClipping(TestCaseMixin, unittest.TestCase):
|
||||
device = "cuda:0"
|
||||
mesh1 = torus(20.0, 85.0, 32, 16, device=device)
|
||||
mesh2 = torus(2.0, 3.0, 32, 16, device=device)
|
||||
for (mesh, z_clip) in [(mesh1, None), (mesh2, 5.0)]:
|
||||
for mesh, z_clip in [(mesh1, None), (mesh2, 5.0)]:
|
||||
tex = TexturesVertex(verts_features=torch.rand_like(mesh.verts_padded()))
|
||||
mesh.textures = tex
|
||||
raster_settings = RasterizationSettings(
|
||||
|
||||
@@ -384,7 +384,7 @@ class TestRenderPoints(TestCaseMixin, unittest.TestCase):
|
||||
(AlphaCompositor, alpha_composite),
|
||||
]
|
||||
|
||||
for (compositor_class, composite_func) in compositor_funcs:
|
||||
for compositor_class, composite_func in compositor_funcs:
|
||||
|
||||
compositor = compositor_class(background_color)
|
||||
|
||||
@@ -435,7 +435,7 @@ class TestRenderPoints(TestCaseMixin, unittest.TestCase):
|
||||
(AlphaCompositor, alpha_composite),
|
||||
]
|
||||
|
||||
for (compositor_class, composite_func) in compositor_funcs:
|
||||
for compositor_class, composite_func in compositor_funcs:
|
||||
|
||||
compositor = compositor_class(background_color)
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ class TestRenderVolumes(TestCaseMixin, unittest.TestCase):
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
|
||||
frames = []
|
||||
for (image, image_pts) in zip(images, images_pts):
|
||||
for image, image_pts in zip(images, images_pts):
|
||||
diff_image = (
|
||||
((image - image_pts) * 0.5 + 0.5)
|
||||
.mean(dim=2, keepdim=True)
|
||||
|
||||
@@ -100,7 +100,7 @@ class TestVertAlign(TestCaseMixin, unittest.TestCase):
|
||||
def init_feats(batch_size: int = 10, num_channels: int = 256, device: str = "cuda"):
|
||||
H, W = [14, 28], [14, 28]
|
||||
feats = []
|
||||
for (h, w) in zip(H, W):
|
||||
for h, w in zip(H, W):
|
||||
feats.append(torch.rand((batch_size, num_channels, h, w), device=device))
|
||||
return feats
|
||||
|
||||
|
||||
Reference in New Issue
Block a user