Spaces:
Paused
Paused
Upload pytorch3d_stub/pytorch3d/structures/__init__.py with huggingface_hub
Browse files
pytorch3d_stub/pytorch3d/structures/__init__.py
CHANGED
|
@@ -1,5 +1,18 @@
|
|
| 1 |
-
"""pytorch3d.structures stub
|
| 2 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
class Meshes:
|
| 5 |
def __init__(self, verts=None, faces=None, textures=None):
|
|
@@ -16,34 +29,20 @@ class Meshes:
|
|
| 16 |
else:
|
| 17 |
self._faces_list = []
|
| 18 |
self.textures = textures
|
| 19 |
-
|
| 20 |
-
def
|
| 21 |
-
return self._verts_list
|
| 22 |
-
|
| 23 |
-
def faces_list(self):
|
| 24 |
-
return self._faces_list
|
| 25 |
-
|
| 26 |
def verts_packed(self):
|
| 27 |
-
if self._verts_list
|
| 28 |
-
return torch.cat(self._verts_list, dim=0)
|
| 29 |
-
return torch.zeros(0, 3)
|
| 30 |
-
|
| 31 |
def faces_packed(self):
|
| 32 |
-
if self._faces_list
|
| 33 |
-
return torch.cat(self._faces_list, dim=0)
|
| 34 |
-
return torch.zeros(0, 3, dtype=torch.long)
|
| 35 |
-
|
| 36 |
def num_verts_per_mesh(self):
|
| 37 |
return torch.tensor([v.shape[0] for v in self._verts_list])
|
|
|
|
| 38 |
|
| 39 |
-
def __len__(self):
|
| 40 |
-
return len(self._verts_list)
|
| 41 |
|
| 42 |
class Pointclouds:
|
| 43 |
-
"""Minimal Pointclouds stub."""
|
| 44 |
def __init__(self, points=None, features=None, normals=None):
|
| 45 |
self.points_list = points if isinstance(points, list) else ([points] if points is not None else [])
|
| 46 |
self.features_list = features if isinstance(features, list) else ([features] if features is not None else [])
|
| 47 |
self.normals_list = normals if isinstance(normals, list) else ([normals] if normals is not None else [])
|
| 48 |
-
def to(self, device):
|
| 49 |
-
return self
|
|
|
|
| 1 |
+
"""pytorch3d.structures stub with catch-all."""
|
| 2 |
import torch
|
| 3 |
+
import warnings
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def __getattr__(name):
|
| 7 |
+
if name.startswith("_"):
|
| 8 |
+
raise AttributeError(name)
|
| 9 |
+
warnings.warn(f"pytorch3d.structures stub: {name} not implemented", stacklevel=2)
|
| 10 |
+
class _Dummy:
|
| 11 |
+
def __init__(self, *a, **kw): pass
|
| 12 |
+
def to(self, *a, **kw): return self
|
| 13 |
+
_Dummy.__name__ = _Dummy.__qualname__ = name
|
| 14 |
+
return _Dummy
|
| 15 |
+
|
| 16 |
|
| 17 |
class Meshes:
|
| 18 |
def __init__(self, verts=None, faces=None, textures=None):
|
|
|
|
| 29 |
else:
|
| 30 |
self._faces_list = []
|
| 31 |
self.textures = textures
|
| 32 |
+
def verts_list(self): return self._verts_list
|
| 33 |
+
def faces_list(self): return self._faces_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def verts_packed(self):
|
| 35 |
+
return torch.cat(self._verts_list, dim=0) if self._verts_list else torch.zeros(0, 3)
|
|
|
|
|
|
|
|
|
|
| 36 |
def faces_packed(self):
|
| 37 |
+
return torch.cat(self._faces_list, dim=0) if self._faces_list else torch.zeros(0, 3, dtype=torch.long)
|
|
|
|
|
|
|
|
|
|
| 38 |
def num_verts_per_mesh(self):
|
| 39 |
return torch.tensor([v.shape[0] for v in self._verts_list])
|
| 40 |
+
def __len__(self): return len(self._verts_list)
|
| 41 |
|
|
|
|
|
|
|
| 42 |
|
| 43 |
class Pointclouds:
|
|
|
|
| 44 |
def __init__(self, points=None, features=None, normals=None):
|
| 45 |
self.points_list = points if isinstance(points, list) else ([points] if points is not None else [])
|
| 46 |
self.features_list = features if isinstance(features, list) else ([features] if features is not None else [])
|
| 47 |
self.normals_list = normals if isinstance(normals, list) else ([normals] if normals is not None else [])
|
| 48 |
+
def to(self, device): return self
|
|
|