Commit
·
38006c2
1
Parent(s):
ffc0d64
Refactor mesh generation in app.py and update remeshing parameters in inference.py
Browse files- Removed trimesh and KDTree functionality from app.py for simplified mesh handling.
- Adjusted remesh size and iterations in the generate3d function to enhance mesh quality.
- app.py +1 -18
- inference.py +1 -1
app.py
CHANGED
@@ -18,8 +18,6 @@ import json
|
|
18 |
import argparse
|
19 |
import requests
|
20 |
import tempfile
|
21 |
-
import trimesh
|
22 |
-
from scipy.spatial import cKDTree
|
23 |
|
24 |
from model import CRM
|
25 |
from inference import generate3d
|
@@ -278,19 +276,4 @@ with gr.Blocks() as demo:
|
|
278 |
inputs=inputs,
|
279 |
outputs=outputs,
|
280 |
)
|
281 |
-
demo.queue().launch()
|
282 |
-
|
283 |
-
# After mesh generation, fill holes
|
284 |
-
mesh = trimesh.Trimesh(vertices=verts, faces=faces)
|
285 |
-
mesh.fill_holes()
|
286 |
-
|
287 |
-
# Find new vertices (those not in the original set)
|
288 |
-
if mesh.vertices.shape[0] > old_vertices.shape[0]:
|
289 |
-
new_vtx = mesh.vertices[old_vertices.shape[0]:]
|
290 |
-
# Use KDTree to find nearest old vertex for each new vertex
|
291 |
-
tree = cKDTree(old_vertices)
|
292 |
-
dists, idxs = tree.query(new_vtx)
|
293 |
-
new_colors = old_colors[idxs]
|
294 |
-
# Concatenate old and new colors
|
295 |
-
all_colors = np.vstack([old_colors, new_colors])
|
296 |
-
mesh.visual.vertex_colors = all_colors
|
|
|
18 |
import argparse
|
19 |
import requests
|
20 |
import tempfile
|
|
|
|
|
21 |
|
22 |
from model import CRM
|
23 |
from inference import generate3d
|
|
|
276 |
inputs=inputs,
|
277 |
outputs=outputs,
|
278 |
)
|
279 |
+
demo.queue().launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inference.py
CHANGED
@@ -63,7 +63,7 @@ def generate3d(model, rgb, ccm, device):
|
|
63 |
verts, faces = clean_mesh(
|
64 |
data_config['verts'].squeeze().cpu().numpy().astype(np.float32),
|
65 |
data_config['faces'].squeeze().cpu().numpy().astype(np.int32),
|
66 |
-
repair=False, remesh=True, remesh_size=0.
|
67 |
)
|
68 |
data_config['verts'] = torch.from_numpy(verts).to(device).contiguous()
|
69 |
data_config['faces'] = torch.from_numpy(faces).to(device).contiguous()
|
|
|
63 |
verts, faces = clean_mesh(
|
64 |
data_config['verts'].squeeze().cpu().numpy().astype(np.float32),
|
65 |
data_config['faces'].squeeze().cpu().numpy().astype(np.int32),
|
66 |
+
repair=False, remesh=True, remesh_size=0.01, remesh_iters=2
|
67 |
)
|
68 |
data_config['verts'] = torch.from_numpy(verts).to(device).contiguous()
|
69 |
data_config['faces'] = torch.from_numpy(faces).to(device).contiguous()
|