Upload dataset_post_processing.py with huggingface_hub
Browse files- dataset_post_processing.py +44 -0
dataset_post_processing.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def execute_in_directory(directory, command):
|
| 7 |
+
original_dir = os.getcwd()
|
| 8 |
+
try:
|
| 9 |
+
os.chdir(directory)
|
| 10 |
+
result = subprocess.run(
|
| 11 |
+
command,
|
| 12 |
+
shell=True,
|
| 13 |
+
check=True,
|
| 14 |
+
stdout=subprocess.PIPE,
|
| 15 |
+
stderr=subprocess.PIPE,
|
| 16 |
+
text=True
|
| 17 |
+
)
|
| 18 |
+
# print(f"success:\n{result.stdout}")
|
| 19 |
+
return result.returncode
|
| 20 |
+
except subprocess.CalledProcessError as e:
|
| 21 |
+
print(f"error:\n{e.stderr}")
|
| 22 |
+
return e.returncode
|
| 23 |
+
finally:
|
| 24 |
+
os.chdir(original_dir)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def main(root_dir):
|
| 28 |
+
for root, _, files in os.walk(root_dir):
|
| 29 |
+
if "scene.usd" in files:
|
| 30 |
+
if os.path.exists(os.path.join(root, "SubUSDs")):
|
| 31 |
+
bash_command = "rm ./SubUSDs"
|
| 32 |
+
execute_in_directory(root, bash_command)
|
| 33 |
+
|
| 34 |
+
bash_command = "ln -s ../SubUSDs ./SubUSDs"
|
| 35 |
+
execute_in_directory(root, bash_command)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
parser = argparse.ArgumentParser(description='add soft link file')
|
| 40 |
+
parser.add_argument('val_dataset_path',
|
| 41 |
+
type=str,
|
| 42 |
+
help='dataset path')
|
| 43 |
+
args = parser.parse_args()
|
| 44 |
+
main(args.val_dataset_path)
|