forked from jmu201521121021/RobustVideoMatting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_shell_cmd.py
62 lines (44 loc) · 2.06 KB
/
run_shell_cmd.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import glob
import os
import subprocess
def gen_output_path(INPUT_VIDEO):
# Generate output path
dirname = os.path.dirname(INPUT_VIDEO)
basename_without_ext = os.path.splitext(os.path.basename(INPUT_VIDEO))[0]
#print(dirname, basename_without_ext)
OUTPUT_COMP = os.path.join(dirname, basename_without_ext + "_ecs_comp.MP4")
OUTPUT_ALPHA = os.path.join(dirname, basename_without_ext + "_ecs_alpha.MP4")
#print (OUTPUT_COMP, OUTPUT_ALPHA)
return OUTPUT_COMP, OUTPUT_ALPHA
def run_rvm_cmd(INPUT_VIDEO):
# Generate output path
OUTPUT_COMP, OUTPUT_ALPHA = gen_output_path(INPUT_VIDEO)
print ("INPUT_VIDEO:", INPUT_VIDEO)
print ("OUTPUT_COMP:", OUTPUT_COMP)
print ("OUTPUT_ALPHA:", OUTPUT_ALPHA)
# run RVM_cmd
result = subprocess.call(["python3", "inference.py",
"--variant", "resnet50",
"--checkpoint", "rvm_resnet50.pth",
"--device", "cuda",
"--input-source", INPUT_VIDEO,
"--output-type", "video",
#"--downsample-ratio", "0.4",
"--output-composition", OUTPUT_COMP,
"--output-alpha", OUTPUT_ALPHA,
"--output-video-mbps", "4",
"--seq-chunk", "1"])
return result
if __name__ == '__main__':
FILES_DIR = "/data2/20210803_Sancyoku_user_data"
#FILES_DIR = "./test_sancyoku"
# test_list = [*glob.glob(os.path.join(FILES_DIR, '**', '*.MOV'), recursive=True)]
# print(test_list, len(test_list))
# Get All File Path
file_list = sorted([*glob.glob(os.path.join(FILES_DIR, '**', '*.MOV'), recursive=True),
*glob.glob(os.path.join(FILES_DIR, '**', '*.mp4'), recursive=True)])
#print(file_list, len(file_list))
#Loop
for idx, video_file in enumerate(file_list):
print(idx, "/", len(file_list))
result = run_rvm_cmd(video_file)