Spaces:
Running
on
Zero
Running
on
Zero
hengli
commited on
Commit
·
f661d26
1
Parent(s):
d8b386f
update hf link
Browse files- visual_util.py +9 -3
visual_util.py
CHANGED
|
@@ -76,6 +76,7 @@ def predictions_to_glb(
|
|
| 76 |
pred_world_points_conf = predictions.get(
|
| 77 |
"world_points_conf", np.ones_like(pred_world_points[..., 0])
|
| 78 |
)
|
|
|
|
| 79 |
else:
|
| 80 |
print(
|
| 81 |
"Warning: world_points not found in predictions, falling back to depth-based points"
|
|
@@ -84,18 +85,22 @@ def predictions_to_glb(
|
|
| 84 |
pred_world_points_conf = predictions.get(
|
| 85 |
"depth_conf", np.ones_like(pred_world_points[..., 0])
|
| 86 |
)
|
|
|
|
| 87 |
else:
|
| 88 |
print("Using Depthmap and Camera Branch")
|
| 89 |
pred_world_points = predictions["world_points_from_depth"]
|
| 90 |
pred_world_points_conf = predictions.get(
|
| 91 |
"depth_conf", np.ones_like(pred_world_points[..., 0])
|
| 92 |
)
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Get images from predictions
|
| 95 |
images = predictions["images"]
|
| 96 |
# Use extrinsic matrices instead of pred_extrinsic_list
|
| 97 |
camera_matrices = predictions["extrinsic"]
|
| 98 |
-
|
|
|
|
| 99 |
if mask_sky:
|
| 100 |
if target_dir is not None:
|
| 101 |
import onnxruntime
|
|
@@ -154,7 +159,7 @@ def predictions_to_glb(
|
|
| 154 |
pred_world_points_conf = pred_world_points_conf[selected_frame_idx][None]
|
| 155 |
images = images[selected_frame_idx][None]
|
| 156 |
camera_matrices = camera_matrices[selected_frame_idx][None]
|
| 157 |
-
|
| 158 |
vertices_3d = pred_world_points.reshape(-1, 3)
|
| 159 |
# Handle different image formats - check if images need transposing
|
| 160 |
if images.ndim == 4 and images.shape[1] == 3: # NCHW format
|
|
@@ -185,7 +190,8 @@ def predictions_to_glb(
|
|
| 185 |
& (colors_rgb[:, 2] > 240)
|
| 186 |
)
|
| 187 |
conf_mask = conf_mask & white_bg_mask
|
| 188 |
-
|
|
|
|
| 189 |
vertices_3d = vertices_3d[conf_mask]
|
| 190 |
colors_rgb = colors_rgb[conf_mask]
|
| 191 |
|
|
|
|
| 76 |
pred_world_points_conf = predictions.get(
|
| 77 |
"world_points_conf", np.ones_like(pred_world_points[..., 0])
|
| 78 |
)
|
| 79 |
+
|
| 80 |
else:
|
| 81 |
print(
|
| 82 |
"Warning: world_points not found in predictions, falling back to depth-based points"
|
|
|
|
| 85 |
pred_world_points_conf = predictions.get(
|
| 86 |
"depth_conf", np.ones_like(pred_world_points[..., 0])
|
| 87 |
)
|
| 88 |
+
|
| 89 |
else:
|
| 90 |
print("Using Depthmap and Camera Branch")
|
| 91 |
pred_world_points = predictions["world_points_from_depth"]
|
| 92 |
pred_world_points_conf = predictions.get(
|
| 93 |
"depth_conf", np.ones_like(pred_world_points[..., 0])
|
| 94 |
)
|
| 95 |
+
print(f"pred_world_points shape: {pred_world_points.shape}")
|
| 96 |
+
print(f"pred_world_points_conf shape: {pred_world_points_conf.shape}")
|
| 97 |
|
| 98 |
# Get images from predictions
|
| 99 |
images = predictions["images"]
|
| 100 |
# Use extrinsic matrices instead of pred_extrinsic_list
|
| 101 |
camera_matrices = predictions["extrinsic"]
|
| 102 |
+
print(f"images shape: {images.shape}")
|
| 103 |
+
print(f"camera_matrices shape: {camera_matrices.shape}")
|
| 104 |
if mask_sky:
|
| 105 |
if target_dir is not None:
|
| 106 |
import onnxruntime
|
|
|
|
| 159 |
pred_world_points_conf = pred_world_points_conf[selected_frame_idx][None]
|
| 160 |
images = images[selected_frame_idx][None]
|
| 161 |
camera_matrices = camera_matrices[selected_frame_idx][None]
|
| 162 |
+
# print
|
| 163 |
vertices_3d = pred_world_points.reshape(-1, 3)
|
| 164 |
# Handle different image formats - check if images need transposing
|
| 165 |
if images.ndim == 4 and images.shape[1] == 3: # NCHW format
|
|
|
|
| 190 |
& (colors_rgb[:, 2] > 240)
|
| 191 |
)
|
| 192 |
conf_mask = conf_mask & white_bg_mask
|
| 193 |
+
print(f"Total points before filtering: {len(vertices_3d)}")
|
| 194 |
+
print(f"Total points after filtering: {conf_mask.sum()}")
|
| 195 |
vertices_3d = vertices_3d[conf_mask]
|
| 196 |
colors_rgb = colors_rgb[conf_mask]
|
| 197 |
|