From 4bc57b606755eeb011b85e145efb23f44d7d40f5 Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Fri, 27 Jan 2023 19:55:58 +0000 Subject: [PATCH] geenrate curv based on frames file --- curvature_label_parallel.py | 7 ++++--- curvature_labels.py | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/curvature_label_parallel.py b/curvature_label_parallel.py index 9a01f4f..d426f07 100644 --- a/curvature_label_parallel.py +++ b/curvature_label_parallel.py @@ -9,10 +9,11 @@ if __name__ == '__main__': ids = os.listdir(folder + '/mesh_posed') count = 0 - step = 15000 + step = 5000 - while count < len(ids): + # while count < len(ids): + while count < 30000: # 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_50_train_nons_' + str(count) + '_' + str(count+step) + ' > nohup/curv_gen_50_train_nons_' + 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_50_train_' + str(count) + '_' + str(count+step) + ' > nohup/curv_gen_50_train_' + 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 diff --git a/curvature_labels.py b/curvature_labels.py index c6b72ec..73035c1 100644 --- a/curvature_labels.py +++ b/curvature_labels.py @@ -83,9 +83,9 @@ def k_neighbours(k): pass -def calculate_dist(folder, neighbourhood): +def calculate_dist(folder, neighbourhood, frames): out = dict() - frames = sorted(os.listdir(os.path.join(folder, 'mesh_posed')))[int(args.start):int(args.end)] + # frames = frames[int(args.start):int(args.end)] for frame in tqdm.tqdm(frames): id = frame.split('_')[0] @@ -98,13 +98,13 @@ def calculate_dist(folder, neighbourhood): return out -def generate_curvatures(folder, neighbourhood): +def generate_curvatures(folder, neighbourhood, frames): # ids = os.listdir(folder)[int(args.start):int(args.end)] - frames = sorted(os.listdir(os.path.join(folder, 'mesh_posed')))[int(args.start):int(args.end)] + # frames = frames[int(args.start):int(args.end)] os.makedirs(os.path.join(folder, f'mesh_curvature_raw_{neighbourhood}'), exist_ok=True) - k_neighbors_cache = calculate_dist(folder, neighbourhood) + k_neighbors_cache = calculate_dist(folder, neighbourhood, frames) for frame in tqdm.tqdm(frames): @@ -295,6 +295,8 @@ if __name__ == '__main__': # k_neighbours(k=25) folder = args.folder + frames_file = 'frames' + skirt_modifier + '_10p.txt' + nr_of_labels = 6 neighbourhood = 50 temp_file = '/home/workspace/local-data/temp/' + ''.join(random.choice(string.ascii_lowercase) for i in range(10)) + '.ply' @@ -305,7 +307,15 @@ if __name__ == '__main__': print('SKIRT' if is_skirt else 'NOT SKIRT') - generate_curvatures(folder, neighbourhood) + # frames = sorted(os.listdir(os.path.join(folder, 'mesh_posed')))[int(args.start):int(args.end)] + + frames = [] + with open(os.path.join(folder, frames_file), 'r') as f: + lines = f.readlines() + 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) # bins = get_bins(curvatures, nr_of_labels) # np.save('train_bins_skirt.npy', bins)