@@ -109,17 +109,17 @@ def _pad_texture_maps(
109
109
Pad all texture images so they have the same height and width.
110
110
111
111
Args:
112
- images: list of N tensors of shape (H_i, W_i, 3 )
112
+ images: list of N tensors of shape (H_i, W_i, C )
113
113
align_corners: used for interpolation
114
114
115
115
Returns:
116
- tex_maps: Tensor of shape (N, max_H, max_W, 3 )
116
+ tex_maps: Tensor of shape (N, max_H, max_W, C )
117
117
"""
118
118
tex_maps = []
119
119
max_H = 0
120
120
max_W = 0
121
121
for im in images :
122
- h , w , _3 = im .shape
122
+ h , w , _C = im .shape
123
123
if h > max_H :
124
124
max_H = h
125
125
if w > max_W :
@@ -134,7 +134,7 @@ def _pad_texture_maps(
134
134
image_BCHW , size = max_shape , mode = "bilinear" , align_corners = align_corners
135
135
)
136
136
tex_maps [i ] = new_image_BCHW [0 ].permute (1 , 2 , 0 )
137
- tex_maps = torch .stack (tex_maps , dim = 0 ) # (num_tex_maps, max_H, max_W, 3 )
137
+ tex_maps = torch .stack (tex_maps , dim = 0 ) # (num_tex_maps, max_H, max_W, C )
138
138
return tex_maps
139
139
140
140
@@ -288,12 +288,12 @@ def Textures(
288
288
289
289
Args:
290
290
maps: texture map per mesh. This can either be a list of maps
291
- [(H, W, 3 )] or a padded tensor of shape (N, H, W, 3 ).
291
+ [(H, W, C )] or a padded tensor of shape (N, H, W, C ).
292
292
faces_uvs: (N, F, 3) tensor giving the index into verts_uvs for each
293
293
vertex in the face. Padding value is assumed to be -1.
294
294
verts_uvs: (N, V, 2) tensor giving the uv coordinate per vertex.
295
- verts_rgb: (N, V, 3 ) tensor giving the rgb color per vertex. Padding
296
- value is assumed to be -1.
295
+ verts_rgb: (N, V, C ) tensor giving the color per vertex. Padding
296
+ value is assumed to be -1. (C=3 for RGB.)
297
297
298
298
299
299
Returns:
@@ -327,7 +327,7 @@ def __init__(self, atlas: Union[torch.Tensor, List[torch.Tensor]]):
327
327
This is based on the implementation from SoftRasterizer [1].
328
328
329
329
Args:
330
- atlas: (N, F, R, R, D ) tensor giving the per face texture map.
330
+ atlas: (N, F, R, R, C ) tensor giving the per face texture map.
331
331
The atlas can be created during obj loading with the
332
332
pytorch3d.io.load_obj function - in the input arguments
333
333
set `create_texture_atlas=True`. The atlas will be
@@ -354,7 +354,7 @@ def __init__(self, atlas: Union[torch.Tensor, List[torch.Tensor]]):
354
354
)
355
355
if not correct_format :
356
356
msg = (
357
- "Expected atlas to be a list of tensors of shape (F, R, R, D ) "
357
+ "Expected atlas to be a list of tensors of shape (F, R, R, C ) "
358
358
"with the same value of R."
359
359
)
360
360
raise ValueError (msg )
@@ -373,7 +373,7 @@ def __init__(self, atlas: Union[torch.Tensor, List[torch.Tensor]]):
373
373
374
374
elif torch .is_tensor (atlas ):
375
375
if atlas .ndim != 5 :
376
- msg = "Expected atlas to be of shape (N, F, R, R, D ); got %r"
376
+ msg = "Expected atlas to be of shape (N, F, R, R, C ); got %r"
377
377
raise ValueError (msg % repr (atlas .ndim ))
378
378
self ._atlas_padded = atlas
379
379
self ._atlas_list = None
@@ -499,7 +499,7 @@ def sample_textures(self, fragments, **kwargs) -> torch.Tensor:
499
499
representation) which overlap the pixel.
500
500
501
501
Returns:
502
- texels: (N, H, W, K, 3 )
502
+ texels: (N, H, W, K, C )
503
503
"""
504
504
N , H , W , K = fragments .pix_to_face .shape
505
505
atlas_packed = self .atlas_packed ()
@@ -532,7 +532,7 @@ def faces_verts_textures_packed(self) -> torch.Tensor:
532
532
"""
533
533
Samples texture from each vertex for each face in the mesh.
534
534
For N meshes with {Fi} number of faces, it returns a
535
- tensor of shape sum(Fi)x3xD (D = 3 for RGB).
535
+ tensor of shape sum(Fi)x3xC (C = 3 for RGB).
536
536
You can use the utils function in structures.utils to convert the
537
537
packed representation to a list or padded.
538
538
"""
@@ -603,7 +603,8 @@ def __init__(
603
603
604
604
Args:
605
605
maps: texture map per mesh. This can either be a list of maps
606
- [(H, W, 3)] or a padded tensor of shape (N, H, W, 3)
606
+ [(H, W, C)] or a padded tensor of shape (N, H, W, C).
607
+ For RGB, C = 3.
607
608
faces_uvs: (N, F, 3) LongTensor giving the index into verts_uvs
608
609
for each face
609
610
verts_uvs: (N, V, 2) tensor giving the uv coordinates per vertex
@@ -708,7 +709,7 @@ def __init__(
708
709
709
710
if isinstance (maps , torch .Tensor ):
710
711
if maps .ndim != 4 or maps .shape [0 ] != self ._N :
711
- msg = "Expected maps to be of shape (N, H, W, 3 ); got %r"
712
+ msg = "Expected maps to be of shape (N, H, W, C ); got %r"
712
713
raise ValueError (msg % repr (maps .shape ))
713
714
self ._maps_padded = maps
714
715
self ._maps_list = None
@@ -1061,8 +1062,8 @@ def _place_map_into_single_map(
1061
1062
Used by join_scene.
1062
1063
1063
1064
Args:
1064
- single_map: (total_H, total_W, 3 )
1065
- map_: (H, W, 3 ) source data
1065
+ single_map: (total_H, total_W, C )
1066
+ map_: (H, W, C ) source data
1066
1067
location: where to place map
1067
1068
"""
1068
1069
do_flip = location .flipped
@@ -1246,10 +1247,10 @@ def __init__(
1246
1247
):
1247
1248
"""
1248
1249
Batched texture representation where each vertex in a mesh
1249
- has a D dimensional feature vector.
1250
+ has a C dimensional feature vector.
1250
1251
1251
1252
Args:
1252
- verts_features: list of (Vi, D ) or (N, V, D ) tensor giving a feature
1253
+ verts_features: list of (Vi, C ) or (N, V, C ) tensor giving a feature
1253
1254
vector with arbitrary dimensions for each vertex.
1254
1255
"""
1255
1256
if isinstance (verts_features , (tuple , list )):
@@ -1258,7 +1259,7 @@ def __init__(
1258
1259
)
1259
1260
if not correct_shape :
1260
1261
raise ValueError (
1261
- "Expected verts_features to be a list of tensors of shape (V, D )."
1262
+ "Expected verts_features to be a list of tensors of shape (V, C )."
1262
1263
)
1263
1264
1264
1265
self ._verts_features_list = verts_features
@@ -1276,7 +1277,7 @@ def __init__(
1276
1277
1277
1278
elif torch .is_tensor (verts_features ):
1278
1279
if verts_features .ndim != 3 :
1279
- msg = "Expected verts_features to be of shape (N, V, D ); got %r"
1280
+ msg = "Expected verts_features to be of shape (N, V, C ); got %r"
1280
1281
raise ValueError (msg % repr (verts_features .shape ))
1281
1282
self ._verts_features_padded = verts_features
1282
1283
self ._verts_features_list = None
0 commit comments