File size: 1,466 Bytes
586fccb
cf92dec
 
 
9e2567f
 
586fccb
9e2567f
 
 
586fccb
9e2567f
 
 
 
586fccb
 
 
 
 
 
 
 
9e2567f
 
 
586fccb
 
9e2567f
 
586fccb
 
9e2567f
 
586fccb
 
9e2567f
 
586fccb
9e2567f
 
 
 
 
 
 
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
45
46
47
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")

    try:
        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,
        )
        run_and_check(
            [sys.executable, "-u", "run_facer_segmentation.py", "--video_name", vid_name],
            cwd=SCRIPTS,
        )
    except subprocess.CalledProcessError as e:
        print(f"ERROR: {e.cmd!r} exited with {e.returncode}", file=sys.stderr)
        print("---- STDOUT ----", file=sys.stderr)
        print(e.stdout, file=sys.stderr)
        print("---- STDERR ----", file=sys.stderr)
        sys.exit(e.returncode)

if __name__ == "__main__":
    tyro.cli(main)