mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 20:02:49 +08:00
Old-style string formatting fails when passed a tuple.
Summary: When the error occurs, another exception is thrown when tensor shape is passed to the % formatting. I have found all entries for `msg %` and fixed potential failures Reviewed By: nikhilaravi Differential Revision: D20386511 fbshipit-source-id: c05413eb4867cab1ddc9615dffbd0ebd3adfcaf9
This commit is contained in:
parent
fb97ab104e
commit
cae325718e
@ -905,7 +905,7 @@ def get_world_to_view_transform(R=r, T=t) -> Transform3d:
|
|||||||
raise ValueError(msg % repr(T.shape))
|
raise ValueError(msg % repr(T.shape))
|
||||||
if R.dim() != 3 or R.shape[1:] != (3, 3):
|
if R.dim() != 3 or R.shape[1:] != (3, 3):
|
||||||
msg = "Expected R to have shape (N, 3, 3); got %r"
|
msg = "Expected R to have shape (N, 3, 3); got %r"
|
||||||
raise ValueError(msg % R.shape)
|
raise ValueError(msg % repr(R.shape))
|
||||||
|
|
||||||
# Create a Transform3d object
|
# Create a Transform3d object
|
||||||
T = Translate(T, device=T.device)
|
T = Translate(T, device=T.device)
|
||||||
|
@ -19,7 +19,7 @@ def _clip_barycentric_coordinates(bary) -> torch.Tensor:
|
|||||||
"""
|
"""
|
||||||
if bary.shape[-1] != 3:
|
if bary.shape[-1] != 3:
|
||||||
msg = "Expected barycentric coords to have last dim = 3; got %r"
|
msg = "Expected barycentric coords to have last dim = 3; got %r"
|
||||||
raise ValueError(msg % bary.shape)
|
raise ValueError(msg % (bary.shape,))
|
||||||
clipped = bary.clamp(min=0.0)
|
clipped = bary.clamp(min=0.0)
|
||||||
clipped_sum = torch.clamp(clipped.sum(dim=-1, keepdim=True), min=1e-5)
|
clipped_sum = torch.clamp(clipped.sum(dim=-1, keepdim=True), min=1e-5)
|
||||||
clipped = clipped / clipped_sum
|
clipped = clipped / clipped_sum
|
||||||
@ -57,7 +57,7 @@ def interpolate_face_attributes(
|
|||||||
N, H, W, K, _ = barycentric_coords.shape
|
N, H, W, K, _ = barycentric_coords.shape
|
||||||
if pix_to_face.shape != (N, H, W, K):
|
if pix_to_face.shape != (N, H, W, K):
|
||||||
msg = "pix_to_face must have shape (batch_size, H, W, K); got %r"
|
msg = "pix_to_face must have shape (batch_size, H, W, K); got %r"
|
||||||
raise ValueError(msg % pix_to_face.shape)
|
raise ValueError(msg % (pix_to_face.shape,))
|
||||||
|
|
||||||
# Replace empty pixels in pix_to_face with 0 in order to interpolate.
|
# Replace empty pixels in pix_to_face with 0 in order to interpolate.
|
||||||
mask = pix_to_face == -1
|
mask = pix_to_face == -1
|
||||||
|
@ -103,7 +103,7 @@ class Textures(object):
|
|||||||
raise ValueError(msg % repr(faces_uvs.shape))
|
raise ValueError(msg % repr(faces_uvs.shape))
|
||||||
if verts_rgb is not None and verts_rgb.ndim != 3:
|
if verts_rgb is not None and verts_rgb.ndim != 3:
|
||||||
msg = "Expected verts_rgb to be of shape (N, V, 3); got %r"
|
msg = "Expected verts_rgb to be of shape (N, V, 3); got %r"
|
||||||
raise ValueError(msg % verts_rgb.shape)
|
raise ValueError(msg % repr(verts_rgb.shape))
|
||||||
if maps is not None:
|
if maps is not None:
|
||||||
if torch.is_tensor(maps) and maps.ndim != 4:
|
if torch.is_tensor(maps) and maps.ndim != 4:
|
||||||
msg = "Expected maps to be of shape (N, H, W, 3); got %r"
|
msg = "Expected maps to be of shape (N, H, W, 3); got %r"
|
||||||
|
@ -275,7 +275,7 @@ class Transform3d:
|
|||||||
points_batch = points_batch[None] # (P, 3) -> (1, P, 3)
|
points_batch = points_batch[None] # (P, 3) -> (1, P, 3)
|
||||||
if points_batch.dim() != 3:
|
if points_batch.dim() != 3:
|
||||||
msg = "Expected points to have dim = 2 or dim = 3: got shape %r"
|
msg = "Expected points to have dim = 2 or dim = 3: got shape %r"
|
||||||
raise ValueError(msg % points.shape)
|
raise ValueError(msg % repr(points.shape))
|
||||||
|
|
||||||
N, P, _3 = points_batch.shape
|
N, P, _3 = points_batch.shape
|
||||||
ones = torch.ones(N, P, 1, dtype=points.dtype, device=points.device)
|
ones = torch.ones(N, P, 1, dtype=points.dtype, device=points.device)
|
||||||
@ -309,7 +309,7 @@ class Transform3d:
|
|||||||
"""
|
"""
|
||||||
if normals.dim() not in [2, 3]:
|
if normals.dim() not in [2, 3]:
|
||||||
msg = "Expected normals to have dim = 2 or dim = 3: got shape %r"
|
msg = "Expected normals to have dim = 2 or dim = 3: got shape %r"
|
||||||
raise ValueError(msg % normals.shape)
|
raise ValueError(msg % (normals.shape,))
|
||||||
composed_matrix = self.get_matrix()
|
composed_matrix = self.get_matrix()
|
||||||
|
|
||||||
# TODO: inverse is bad! Solve a linear system instead
|
# TODO: inverse is bad! Solve a linear system instead
|
||||||
|
Loading…
x
Reference in New Issue
Block a user