save progress
This commit is contained in:
+8
-25
@@ -114,14 +114,6 @@ class Cache:
|
||||
|
||||
mask = read_garment_mask(self.folder, id, garment)
|
||||
|
||||
if self.include_neighbours:
|
||||
k_neighbors = np.argsort(dist[mask, :][:, mask], axis=-1)[:, :self.neighbourhood]
|
||||
self.cache[id].k_neighbors = k_neighbors
|
||||
G = tm.graph.vertex_adjacency_graph(m)
|
||||
for i in range(v.shape[0]):
|
||||
for k in range(25):
|
||||
assert nx.has_path(G, i, k_neighbors[i, k]), f'No path between {i} and {k_neighbors[i, k]}'
|
||||
|
||||
_, faces = _maskFaces(np.zeros((14475,3)), F, mask)
|
||||
v = read_posed_garment_frame(folder, id, garment, 0)[mask,:]
|
||||
m = tm.Trimesh(v, faces, process=False, validate=False)
|
||||
@@ -132,6 +124,14 @@ class Cache:
|
||||
faces = np.concatenate((faces, outliers_faces), axis=0)
|
||||
m = tm.Trimesh(v, faces, process=False, validate=False)
|
||||
|
||||
if self.include_neighbours:
|
||||
k_neighbors = np.argsort(dist[mask, :][:, mask], axis=-1)[:, :self.neighbourhood]
|
||||
self.cache[id].k_neighbors = k_neighbors
|
||||
G = tm.graph.vertex_adjacency_graph(m)
|
||||
for i in range(v.shape[0]):
|
||||
for k in range(25):
|
||||
assert nx.has_path(G, i, k_neighbors[i, k]), f'No path between {i} and {k_neighbors[i, k]}'
|
||||
|
||||
self.cache[id].mask = mask
|
||||
self.cache[id].faces = faces
|
||||
|
||||
@@ -162,7 +162,6 @@ def calculate_dist(folder, neighbourhood, frames):
|
||||
|
||||
|
||||
def generate_curvatures(folder, neighbourhood, frames):
|
||||
|
||||
# ids = os.listdir(folder)[int(args.start):int(args.end)]
|
||||
# frames = frames[int(args.start):int(args.end)]
|
||||
os.makedirs(os.path.join('/'.join(folder.split('/')[:-1]), 'backup', f'mesh_curvature_raw'), exist_ok=True)
|
||||
@@ -176,9 +175,6 @@ def generate_curvatures(folder, neighbourhood, frames):
|
||||
frame_nr = int(frame.split()[1])
|
||||
garment = frame.split()[2]
|
||||
|
||||
# bodies = readPC2(os.path.join(folder, id, 'Body_posed.pc16'), True)['V']
|
||||
# offsetss = readPC2(os.path.join(folder, id, garment + '_registered.pc16'), True)['V']
|
||||
# mask = np.load(os.path.join(folder, 'mesh_mask', f'{id}.npy')).astype(bool)
|
||||
mask = cache[id].mask
|
||||
faces = cache[id].faces
|
||||
v = read_posed_garment_frame(folder, id, garment, frame_nr)[mask,:]
|
||||
@@ -193,7 +189,6 @@ def generate_curvatures(folder, neighbourhood, frames):
|
||||
curvature = np.array(cloud.points["curvature(" + str(neighbourhood+1) + ")"])
|
||||
out = np.zeros((14475), dtype=np.float32)
|
||||
out[mask] = curvature
|
||||
|
||||
|
||||
np.savez_compressed(os.path.join('/'.join(folder.split('/')[:-1]), 'backup', f'mesh_curvature_raw', f'{id}_{frame_nr}_{garment}.npz'), mesh_curvature_raw=out)
|
||||
group = h5file.get_node(f'/{id}/{frame_nr}/{garment}')
|
||||
@@ -204,7 +199,6 @@ def generate_curvatures(folder, neighbourhood, frames):
|
||||
carray = h5file.create_carray(group, "curvature_raw", atom=tb.Float32Atom(), shape=out.shape, filters=filters)
|
||||
carray[:] = out
|
||||
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -282,24 +276,13 @@ def visualize_curvature_labels(folder, frames):
|
||||
faces = cache[id].faces
|
||||
verts = read_posed_garment_frame(folder, id, garment, frame_nr)[mask, :]
|
||||
curv = h5file.get_node(f'/{id}/{frame_nr}/{garment}/curvature_mesh_global').read()[mask]
|
||||
|
||||
# m = tm.Trimesh(verts, faces, process=False, validate=False)
|
||||
|
||||
# outliers = np.array([len(v) for v in m.vertex_neighbors]) == 0
|
||||
# outliers = np.nonzero(outliers)[0]
|
||||
# outliers_n_neighbours = get_closest_n_points(verts, outliers, 2)
|
||||
# outliers_faces = np.concatenate((outliers[:, np.newaxis], outliers_n_neighbours), axis=-1)
|
||||
# faces = np.concatenate((faces, outliers_faces), axis=0)
|
||||
|
||||
colors = np.array([cm.color('jet', 1 - i) for i in np.linspace(0, 1, int(curv.max()))])
|
||||
colors_binned = np.zeros((curv.shape[0], 3))
|
||||
for i in range(1, int(curv.max())+1):
|
||||
# print(np.count_nonzero(curv == i))
|
||||
colors_binned[curv == i, :] = colors[i-1]
|
||||
# colors_binned = colors_binned[mask, :]
|
||||
|
||||
# m = tm.Trimesh(verts, faces, process=False, validate=False, vertex_colors=colors_binned)
|
||||
# m.show()
|
||||
x = verts
|
||||
meshes = [go.Mesh3d(
|
||||
x=x[:,0],
|
||||
|
||||
Reference in New Issue
Block a user