Spaces:
Running
on
Zero
Running
on
Zero
Ruining Li
commited on
Commit
·
b195f11
1
Parent(s):
fd3f5ff
Add error message when mesh has >51.2k faces.
Browse files- app.py +9 -0
- infer_asset.py +5 -1
app.py
CHANGED
|
@@ -134,6 +134,15 @@ class ParticulateApp:
|
|
| 134 |
*[None] * 9
|
| 135 |
)
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
except Exception as e:
|
| 138 |
import traceback
|
| 139 |
traceback.print_exc()
|
|
|
|
| 134 |
*[None] * 9
|
| 135 |
)
|
| 136 |
|
| 137 |
+
except ValueError as e:
|
| 138 |
+
# Surface validation errors (e.g., too many faces) directly to the UI
|
| 139 |
+
message = str(e)
|
| 140 |
+
if "faces > 51.2k" in message:
|
| 141 |
+
message = "Mesh has more than 51.2k faces; please reduce the face count."
|
| 142 |
+
return (
|
| 143 |
+
None, None, message,
|
| 144 |
+
*[None] * 9
|
| 145 |
+
)
|
| 146 |
except Exception as e:
|
| 147 |
import traceback
|
| 148 |
traceback.print_exc()
|
infer_asset.py
CHANGED
|
@@ -118,7 +118,11 @@ def sample_points(mesh, num_points, sharp_point_ratio, at_least_one_point_per_fa
|
|
| 118 |
|
| 119 |
if at_least_one_point_per_face:
|
| 120 |
num_faces = len(mesh.faces)
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
# Get a random permutation of face indices
|
| 124 |
face_perm = np.random.permutation(num_faces)
|
|
|
|
| 118 |
|
| 119 |
if at_least_one_point_per_face:
|
| 120 |
num_faces = len(mesh.faces)
|
| 121 |
+
if num_points_uniform < num_faces:
|
| 122 |
+
raise ValueError(
|
| 123 |
+
"Unable to sample at least one point per face: "
|
| 124 |
+
f"{num_faces} faces > 51.2k"
|
| 125 |
+
)
|
| 126 |
|
| 127 |
# Get a random permutation of face indices
|
| 128 |
face_perm = np.random.permutation(num_faces)
|