save
This commit is contained in:
@@ -67,7 +67,7 @@ def get_bins(values, nr_of_bins):
|
||||
return bins
|
||||
|
||||
|
||||
def generate_curvatures(folder, frame, bins, neighbourhoods=[25], nr_of_labels=6):
|
||||
def generate_curvatures(folder, frame, bins, neighbourhoods=[25], nr_of_labels=[6]):
|
||||
id = frame.split('_')[0]
|
||||
frame_nr = int(frame.split('_')[1].split('.')[0])
|
||||
|
||||
@@ -91,14 +91,14 @@ def generate_curvatures(folder, frame, bins, neighbourhoods=[25], nr_of_labels=6
|
||||
cloud = PyntCloud.from_file(temp_file)
|
||||
|
||||
curvatures = []
|
||||
for neighbourhood in neighbourhoods:
|
||||
for neighbourhood, nr_labels in zip(neighbourhoods, nr_of_labels):
|
||||
k_neighbors = np.argsort(dist[mask, :][:, mask], axis=-1)[:, :neighbourhood] #cloud.get_neighbors(k=neighbourhood)
|
||||
#k_neighbors = k_neighbors_cache[id] # np.argsort(dist[mask, :][:, mask], axis=-1)[:, :neighbourhood] #cloud.get_neighbors(k=neighbourhood)
|
||||
ev = cloud.add_scalar_field("eigen_values", k_neighbors=k_neighbors)
|
||||
cloud.add_scalar_field("curvature", ev=ev)
|
||||
curvature = np.array(cloud.points["curvature(" + str(neighbourhood+1) + ")"])
|
||||
|
||||
bins_local = bins[neighbourhood] if bins is not None else get_bins(curvature, nr_of_labels)
|
||||
bins_local = bins[neighbourhood] if bins is not None else get_bins(curvature, nr_labels)
|
||||
labels = np.linspace(0, bins_local.shape[0] - 2, bins_local.shape[0] - 1)
|
||||
|
||||
frame_labels = np.zeros((curvature.shape[0]), dtype=np.float32)
|
||||
@@ -111,7 +111,7 @@ def generate_curvatures(folder, frame, bins, neighbourhoods=[25], nr_of_labels=6
|
||||
return curvatures
|
||||
|
||||
|
||||
def visualize_curvature_labels(folder, frame, bins, neighbourhoods):
|
||||
def visualize_curvature_labels(folder, frame, bins, neighbourhoods, nr_of_labels):
|
||||
id = frame.split('_')[0]
|
||||
frame_nr = frame.split('_')[1].split('.')[0]
|
||||
|
||||
@@ -119,7 +119,7 @@ def visualize_curvature_labels(folder, frame, bins, neighbourhoods):
|
||||
_, faces = _maskFaces(np.zeros((14475,3)), F, mask)
|
||||
verts = np.load(os.path.join(folder, 'mesh_posed', f'{id}_{frame_nr}.npz'))['mesh_posed'][mask,:]
|
||||
|
||||
curvature_labels_all = generate_curvatures(folder, frame, bins, neighbourhoods)
|
||||
curvature_labels_all = generate_curvatures(folder, frame, bins, neighbourhoods, nr_of_labels)
|
||||
colors_binned_all = []
|
||||
|
||||
for curvature_labels in curvature_labels_all:
|
||||
@@ -232,4 +232,4 @@ if __name__ == '__main__':
|
||||
else:
|
||||
dist = np.load('custom_data/dijkstra_skirt.npy')
|
||||
|
||||
visualize_curvature_labels(folder, '02572_1', bins, neighbourhoods=[10, 25, 100])
|
||||
visualize_curvature_labels(folder, '02572_1', bins, neighbourhoods=[25, 25, 25], nr_of_labels=[3,6,12])
|
||||
@@ -4,17 +4,17 @@ import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
folder = '/home/workspace/data/dataset/test_skirt_ready_2'
|
||||
# folder = '/home/workspace/data/dataset/test_skirt_ready_2'
|
||||
# folder = '/home/workspace/data/dataset/local-cache/train_skirt'
|
||||
# folder = '/home/workspace/local-data/valid_skirt'
|
||||
folder = '/home/workspace/local-data/valid_skirt'
|
||||
ids = os.listdir(folder + '/mesh_posed')
|
||||
|
||||
count = 0
|
||||
step = 2500
|
||||
step = 10000
|
||||
|
||||
while count < len(ids):
|
||||
while count < 20*step:
|
||||
# while count < 10000:
|
||||
# os.system('nohup python MeshUtils/curvature_labels.py -f ' + folder + ' -s ' + str(count) + ' -e ' + str(count + step) + ' -n ' + 'curv_train_' + str(count) + '_' + str(count+step) + ' > curv_train_' + str(count) + '_' + str(count+step) + '.out' + ' 2>&1 &')
|
||||
os.system('nohup python curvature_labels.py -f ' + folder + ' -s ' + str(count) + ' -e ' + str(count + step) + ' -n ' + 'curv_gen_2_100_label_test_skirt_' + str(count) + '_' + str(count+step) + ' > nohup/curv_gen_2_100_label_test_skirt_' + str(count) + '_' + str(count+step) + '.out' + ' 2>&1 &')
|
||||
os.system('nohup python curvature_labels.py -f ' + folder + ' -s ' + str(0) + ' -e ' + str(0 + step) + ' -n ' + 'speed_test_' + str(count) + '_' + str(count+step) + ' > nohup/speed/speed_test_' + str(count) + '_' + str(count+step) + '.out' + ' 2>&1 &')
|
||||
# os.system('python Data/convert_to_uv.py -f ' + folder + ' -s ' + str(count) + ' -e ' + str(count + step) + '')
|
||||
count += step
|
||||
|
||||
+29
-29
@@ -106,40 +106,40 @@ def generate_curvatures(folder, neighbourhood, frames):
|
||||
|
||||
k_neighbors_cache = calculate_dist(folder, neighbourhood, frames)
|
||||
|
||||
for frame in tqdm.tqdm(frames):
|
||||
# for frame in tqdm.tqdm(frames):
|
||||
|
||||
id = frame.split('_')[0]
|
||||
frame_nr = frame.split('_')[1].split('.')[0]
|
||||
# id = frame.split('_')[0]
|
||||
# frame_nr = frame.split('_')[1].split('.')[0]
|
||||
|
||||
# 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)
|
||||
_, faces = _maskFaces(np.zeros((14475,3)), F, mask) #np.load(os.path.join(folder, 'faces', f'{id}.npy'))
|
||||
v = np.load(os.path.join(folder, 'mesh_posed', f'{id}_{frame_nr}.npz'))['mesh_posed'][mask,:]
|
||||
# # 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)
|
||||
# _, faces = _maskFaces(np.zeros((14475,3)), F, mask) #np.load(os.path.join(folder, 'faces', f'{id}.npy'))
|
||||
# v = np.load(os.path.join(folder, 'mesh_posed', f'{id}_{frame_nr}.npz'))['mesh_posed'][mask,:]
|
||||
|
||||
m = tm.Trimesh(v, faces, process=False, validate=False)
|
||||
# m = tm.Trimesh(v, 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(v, outliers, 2)
|
||||
outliers_faces = np.concatenate((outliers[:, np.newaxis], outliers_n_neighbours), axis=-1)
|
||||
faces = np.concatenate((faces, outliers_faces), axis=0)
|
||||
# outliers = np.array([len(v) for v in m.vertex_neighbors]) == 0
|
||||
# outliers = np.nonzero(outliers)[0]
|
||||
# outliers_n_neighbours = get_closest_n_points(v, outliers, 2)
|
||||
# outliers_faces = np.concatenate((outliers[:, np.newaxis], outliers_n_neighbours), axis=-1)
|
||||
# faces = np.concatenate((faces, outliers_faces), axis=0)
|
||||
|
||||
verts = v
|
||||
# verts = v
|
||||
|
||||
m = tm.Trimesh(verts, faces, process=False, validate=False)
|
||||
export_to_ply(m, temp_file)
|
||||
# m = tm.Trimesh(verts, faces, process=False, validate=False)
|
||||
# export_to_ply(m, temp_file)
|
||||
|
||||
cloud = PyntCloud.from_file(temp_file)
|
||||
# cloud = PyntCloud.from_file(temp_file)
|
||||
|
||||
k_neighbors = k_neighbors_cache[id] # np.argsort(dist[mask, :][:, mask], axis=-1)[:, :neighbourhood] #cloud.get_neighbors(k=neighbourhood)
|
||||
ev = cloud.add_scalar_field("eigen_values", k_neighbors=k_neighbors)
|
||||
cloud.add_scalar_field("curvature", ev=ev)
|
||||
curvature = np.array(cloud.points["curvature(" + str(neighbourhood+1) + ")"])
|
||||
out = np.zeros((14475), dtype=np.float32)
|
||||
out[mask] = curvature
|
||||
# k_neighbors = k_neighbors_cache[id] # np.argsort(dist[mask, :][:, mask], axis=-1)[:, :neighbourhood] #cloud.get_neighbors(k=neighbourhood)
|
||||
# ev = cloud.add_scalar_field("eigen_values", k_neighbors=k_neighbors)
|
||||
# cloud.add_scalar_field("curvature", ev=ev)
|
||||
# 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(folder, f'mesh_curvature_raw_{neighbourhood}', f'{id}_{frame_nr}.npz'), mesh_curvature_raw=out)
|
||||
# np.savez_compressed(os.path.join(folder, f'mesh_curvature_raw_{neighbourhood}', f'{id}_{frame_nr}.npz'), mesh_curvature_raw=out)
|
||||
|
||||
return None
|
||||
|
||||
@@ -285,12 +285,12 @@ if __name__ == '__main__':
|
||||
# lines = [line.strip() for line in lines]
|
||||
# frames = lines[int(args.start):int(args.end)]
|
||||
|
||||
# generate_curvatures(folder, neighbourhood, frames)
|
||||
curvatures = read_raw_curvatures(folder, frames, neighbourhood)
|
||||
generate_curvatures(folder, neighbourhood, frames)
|
||||
# curvatures = read_raw_curvatures(folder, frames, neighbourhood)
|
||||
# bins = get_bins(curvatures, nr_of_labels)
|
||||
# np.save(f'custom_data/train_bins_skirt_{neighbourhood}.npy', bins)
|
||||
bins = np.load(f'custom_data/train_bins_skirt_{neighbourhood}.npy')
|
||||
generate_curvature_labels(folder, bins, curvatures, frames, neighbourhood)
|
||||
# bins = np.load(f'custom_data/train_bins_skirt_{neighbourhood}.npy')
|
||||
# generate_curvature_labels(folder, bins, curvatures, frames, neighbourhood)
|
||||
# visualize_curvature_labels(folder)
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user