-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathloop_dt2ds.py
67 lines (63 loc) · 2.19 KB
/
loop_dt2ds.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
63
64
65
66
67
#recusively inference detectron2
import os
from tqdm import tqdm
import argparse
def get_parser():
parser = argparse.ArgumentParser(description="inference vids")
parser.add_argument(
"--root_path",
default="/media/data3/EgoCentric_Nafosted/micand30/gt/",
help="Root path",
)
parser.add_argument(
"--config_file",
type=str,
default="/home/minhkv/tienpv_DO_NOT_REMOVE/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml",
help="Config file",
)
parser.add_argument(
"--region_based",
type=str,
default='0',
help="Region based",
)
parser.add_argument(
"--model_weights",
type=str,
default='/home/minhkv/tienpv_DO_NOT_REMOVE/detectron2/projects/micand26_maskrcnnr50fpn3x/output/model_final.pth',
help="Path to model weights",
)
parser.add_argument(
"--tracker",
type=str,
default="sort",
help="sort or deepsort",
)
parser.add_argument(
"--out_vids",
type=str,
default='/media/data3/EgoCentric_Nafosted/micand30/out_vids/mask2s/',
help='Path to folder to save output videos',
)
parser.add_argument(
"--out_txts",
type=str,
default='/media/data3/EgoCentric_Nafosted/micand30/test/mask2s/',
help='Path to folder to save output sequence texts',
)
return parser
def main():
args = get_parser().parse_args()
directories = os.listdir(args.root_path)
for i in tqdm(range(len(directories))):
directory = directories[i]
file_name = directory + '.avi'
input_vid = os.path.join(args.root_path, directory) + '/' + file_name
out_vid = os.path.join(args.out_vids, file_name)
out_txt = os.path.join(args.out_txts, directory+'.txt')
command = 'python3 dt2ds.py --input ' + input_vid + ' --tracker ' + args.tracker + ' --config-file ' + args.config_file + ' --region_based ' + args.region_based + ' --out_vid ' + out_vid + ' --out_txt ' + out_txt + ' --opts MODEL.WEIGHTS ' + args.model_weights
print(command)
os.system(command)
return 0
if __name__ == "__main__":
main()