Spaces:
Running
on
L40S
Running
on
L40S
File size: 1,537 Bytes
2252f3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
import json
def find_files(directory, extensions):
results = []
for foldername, subfolders, filenames in os.walk(directory):
for filename in filenames:
if filename.endswith(extensions):
file_path = os.path.abspath(os.path.join(foldername, filename))
results.append(file_path)
return results
def count_customhumans(root):
directory_path = ['CustomHumans/mesh']
extensions = ('.ply', '.obj')
lists = []
for dataset_path in directory_path:
dir = os.path.join(root, dataset_path)
file_paths = find_files(dir, extensions)
# import pdb;pdb.set_trace()
dataset_name = dataset_path.split('/')[0]
for file_path in file_paths:
lists.append(file_path.replace(root, ""))
with open(f'{dataset_name}.json', 'w') as f:
json.dump(lists, f, indent=4)
def count_thuman21(root):
directory_path = ['THuman2.1/mesh']
extensions = ('.ply', '.obj')
lists = []
for dataset_path in directory_path:
dir = os.path.join(root, dataset_path)
file_paths = find_files(dir, extensions)
dataset_name = dataset_path.split('/')[0]
for file_path in file_paths:
lists.append(file_path.replace(root, ""))
with open(f'{dataset_name}.json', 'w') as f:
json.dump(lists, f, indent=4)
if __name__ == '__main__':
root = '/data/lipeng/human_scan/'
# count_customhumans(root)
count_thuman21(root) |