Commit
·
68935d6
1
Parent(s):
7d064f4
Comment out KDTree functionality in generate3d function to simplify color assignment process. Updated mesh creation to set vertex colors to None, removing reliance on nearest neighbor color mapping.
Browse files- inference.py +8 -8
inference.py
CHANGED
@@ -80,17 +80,17 @@ def generate3d(model, rgb, ccm, device):
|
|
80 |
data_config['verts'] = torch.from_numpy(verts).to(device).contiguous()
|
81 |
data_config['faces'] = torch.from_numpy(faces).to(device).contiguous()
|
82 |
|
83 |
-
# Build KDTree from original verts
|
84 |
-
tree = cKDTree(orig_verts)
|
85 |
|
86 |
-
# For each new vertex, find the nearest old vertex and copy its color
|
87 |
-
k = 3
|
88 |
-
dists, idxs = tree.query(verts, k=k)
|
89 |
-
# Use only the nearest neighbor for color assignment
|
90 |
-
new_colors = orig_colors[idxs[:, 0]]
|
91 |
|
92 |
# Create the new mesh with colors
|
93 |
-
mesh = trimesh.Trimesh(vertices=verts, faces=faces, vertex_colors=
|
94 |
|
95 |
# === Export OBJ/MTL/PNG ===
|
96 |
obj_path = tempfile.NamedTemporaryFile(suffix=".obj", delete=False).name
|
|
|
80 |
data_config['verts'] = torch.from_numpy(verts).to(device).contiguous()
|
81 |
data_config['faces'] = torch.from_numpy(faces).to(device).contiguous()
|
82 |
|
83 |
+
# # Build KDTree from original verts
|
84 |
+
# tree = cKDTree(orig_verts)
|
85 |
|
86 |
+
# # For each new vertex, find the nearest old vertex and copy its color
|
87 |
+
# k = 3
|
88 |
+
# dists, idxs = tree.query(verts, k=k)
|
89 |
+
# # Use only the nearest neighbor for color assignment
|
90 |
+
# new_colors = orig_colors[idxs[:, 0]]
|
91 |
|
92 |
# Create the new mesh with colors
|
93 |
+
mesh = trimesh.Trimesh(vertices=verts, faces=faces, vertex_colors=None)
|
94 |
|
95 |
# === Export OBJ/MTL/PNG ===
|
96 |
obj_path = tempfile.NamedTemporaryFile(suffix=".obj", delete=False).name
|