Spaces:
Runtime error
Runtime error
| import subprocess | |
| import sys | |
| import os | |
| import argparse | |
| import time | |
| from datetime import datetime | |
| import signal | |
| def signal_handler(sig, frame): | |
| print("\nInterrupted by user, shutting down...") | |
| if 'pool' in locals() and pool is not None: | |
| pool.terminate() | |
| pool.join() | |
| sys.exit(0) | |
| signal.signal(signal.SIGINT, signal_handler) | |
| def parse_arguments(): | |
| parser = argparse.ArgumentParser(description="Run the complete video-to-BVH pipeline") | |
| # parser.add_argument('-v', '--video', required=True, help="Path to the input video file") | |
| return parser.parse_args() | |
| def run_command(command, description): | |
| """Run a command and show its output.""" | |
| try: | |
| start_time = time.time() | |
| script_dir = os.path.dirname(command[1]) | |
| current_dir = os.getcwd() | |
| os.chdir(script_dir) | |
| subprocess.run(command, check=True) | |
| os.chdir(current_dir) | |
| end_time = time.time() | |
| execution_time = end_time - start_time | |
| return True | |
| except subprocess.CalledProcessError as e: | |
| os.chdir(current_dir) | |
| return False | |
| except Exception as e: | |
| if 'current_dir' in locals(): | |
| os.chdir(current_dir) | |
| return False | |
| def main(): | |
| args = parse_arguments() | |
| base_dir = os.path.dirname(os.path.abspath(__file__)) | |
| gen_skes_path = os.path.join(base_dir, "VideoToNPZ", "gen_skes.py") | |
| convert_obj_path = os.path.join(base_dir, "convertNPZtoBVH", "conver_obj.py") | |
| convert_bvh_path = os.path.join(base_dir, "convertNPZtoBVH", "conver_bvh.py") | |
| for script_path in [gen_skes_path, convert_obj_path, convert_bvh_path]: | |
| if not os.path.exists(script_path): | |
| return 1 | |
| pipeline_steps = [ | |
| { | |
| "command": [sys.executable, gen_skes_path], | |
| }, | |
| { | |
| "command": [sys.executable, convert_obj_path], | |
| }, | |
| { | |
| "command": [sys.executable, convert_bvh_path], | |
| } | |
| ] | |
| successful = 0 | |
| failed = 0 | |
| for step in pipeline_steps: | |
| if run_command(step["command"], ""): | |
| successful += 1 | |
| else: | |
| failed += 1 | |
| return 0 if failed == 0 else 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) |