Spaces:
Paused
Paused
cpu conversion fixed
Browse files
src/pixel3dmm/tracking/tracker.py
CHANGED
|
@@ -1280,37 +1280,25 @@ class Tracker(object):
|
|
| 1280 |
)
|
| 1281 |
# if they asked *only* for the pure shape mask:
|
| 1282 |
if visualizations == [[View.SHAPE]]:
|
| 1283 |
-
#
|
| 1284 |
normals = ops['normal_images'][0].cpu().numpy() # [3,H,W]
|
| 1285 |
-
#
|
| 1286 |
-
normals = (normals
|
| 1287 |
-
# H×W×3
|
| 1288 |
-
normals = np.transpose(normals, (1, 2, 0))
|
| 1289 |
-
# scale to uint8
|
| 1290 |
arr = (normals * 255).clip(0,255).astype(np.uint8)
|
| 1291 |
|
| 1292 |
-
|
| 1293 |
-
|
| 1294 |
-
|
| 1295 |
-
|
| 1296 |
-
normals = np.transpose(normals, (1,2,0)) # H×W×3
|
| 1297 |
-
arr = (normals * 255).clip(0,255).astype(np.uint8)
|
| 1298 |
-
|
| 1299 |
-
# --- new: export the *non*-canonical mesh ---
|
| 1300 |
-
os.makedirs(self.mesh_folder, exist_ok=True)
|
| 1301 |
-
frame_id = str(self.frame).zfill(5)
|
| 1302 |
-
ply_path = os.path.join(self.mesh_folder, f"{frame_id}.ply")
|
| 1303 |
|
| 1304 |
-
|
| 1305 |
-
|
| 1306 |
-
|
| 1307 |
-
|
| 1308 |
-
verts_np = vertices[0].detach().cpu().numpy()
|
| 1309 |
|
| 1310 |
-
|
| 1311 |
-
.export(ply_path)
|
| 1312 |
|
| 1313 |
-
|
| 1314 |
|
| 1315 |
mask = (self.parse_mask(ops, batch, visualization=True) > 0).float()
|
| 1316 |
grabbed_depth = ops['actual_rendered_depth'][0, 0,
|
|
|
|
| 1280 |
)
|
| 1281 |
# if they asked *only* for the pure shape mask:
|
| 1282 |
if visualizations == [[View.SHAPE]]:
|
| 1283 |
+
# build your normal‐map preview as before
|
| 1284 |
normals = ops['normal_images'][0].cpu().numpy() # [3,H,W]
|
| 1285 |
+
normals = (normals + 1.0) / 2.0 # → [0,1]
|
| 1286 |
+
normals = np.transpose(normals, (1,2,0)) # H×W×3
|
|
|
|
|
|
|
|
|
|
| 1287 |
arr = (normals * 255).clip(0,255).astype(np.uint8)
|
| 1288 |
|
| 1289 |
+
# --- export the posed mesh, using the correct face indices field ---
|
| 1290 |
+
os.makedirs(self.mesh_folder, exist_ok=True)
|
| 1291 |
+
frame_id = str(self.frame).zfill(5)
|
| 1292 |
+
ply_path = os.path.join(self.mesh_folder, f"{frame_id}.ply")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1293 |
|
| 1294 |
+
# pull out the face index tensor
|
| 1295 |
+
faces_np = self.faces.verts_idx.cpu().numpy()
|
| 1296 |
+
# `vertices` is your posed mesh: shape (1, V, 3)
|
| 1297 |
+
verts_np = vertices[0].detach().cpu().numpy()
|
|
|
|
| 1298 |
|
| 1299 |
+
trimesh.Trimesh(faces=faces_np, vertices=verts_np, process=False).export(ply_path)
|
|
|
|
| 1300 |
|
| 1301 |
+
return arr
|
| 1302 |
|
| 1303 |
mask = (self.parse_mask(ops, batch, visualization=True) > 0).float()
|
| 1304 |
grabbed_depth = ops['actual_rendered_depth'][0, 0,
|