Download scripts/run_preprocessing.py from rylann/pixel3dmm: direct link, hf CLI and curl.
- Browser
- Download file 975 Bytes
-
https://huggingface.co/spaces/rylann/pixel3dmm/resolve/main/scripts/run_preprocessing.py
- Command line
-
hf download hf://spaces/rylann/pixel3dmm/scripts/run_preprocessing.py
-
curl -L -o run_preprocessing.py https://huggingface.co/spaces/rylann/pixel3dmm/resolve/main/scripts/run_preprocessing.py
975 Bytes
| import subprocess, sys, os | |
| import tyro | |
| from pixel3dmm import env_paths | |
| def run_and_check(cmd, cwd=None): | |
| print(f"> {' '.join(cmd)} (in {cwd or os.getcwd()})") | |
| # stream logs live | |
| result = subprocess.run( | |
| cmd, | |
| cwd=cwd, | |
| check=True, | |
| ) | |
| return result | |
| def main(video_or_images_path: str): | |
| vid_name = ( | |
| os.path.basename(video_or_images_path) | |
| if os.path.isdir(video_or_images_path) | |
| else os.path.splitext(os.path.basename(video_or_images_path))[0] | |
| ) | |
| SCRIPTS = os.path.join(env_paths.CODE_BASE, "scripts") | |
| MICA = os.path.join(env_paths.CODE_BASE, "src", "pixel3dmm", "preprocessing", "MICA") | |
| run_and_check( | |
| [sys.executable, "-u", "run_cropping.py", "--video_or_images_path", video_or_images_path], | |
| cwd=SCRIPTS, | |
| ) | |
| run_and_check( | |
| [sys.executable, "-u", "demo.py", "-video_name", vid_name], | |
| cwd=MICA, | |
| ) | |
| if __name__ == "__main__": | |
| tyro.cli(main) | |