-
Notifications
You must be signed in to change notification settings - Fork 6
/
batch_blackgen_roi_2bound.py
161 lines (124 loc) · 4.63 KB
/
batch_blackgen_roi_2bound.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import os
import subprocess
from itertools import product
import yaml
# v_list = ['dashcam_%d_test' % (i+1) for i in range(4)] + ['trafficcam_%d_test' % (i+1) for i in range(4)]
# v_list = [v_list[0]]
# v_list = ["youtube_videos/dashcam_%d_crop" % (i + 1) for i in range(4)] + [
# "youtube_videos/trafficcam_%d_crop" % (i + 1) for i in range(4)
# ]
# v_list = ["dashcam/dashcam_%d" % i for i in [2, 5, 6, 8]]
# v_list = ["visdrone/videos/vis_%d" % i for i in range(169, 174)] + [
# "dashcam/dashcam_%d" % i for i in range(1, 11)
# ]
# v_list = ["adapt/drive_%d" % i for i in range(30, 60)]
# v_list = ["dashcam/dashcam_%d" % i for i in [7]]
# v_list = v_list[::-1]
# v_list = [v_list[1]]
# v_list = ["dashcam/dashcam_2"]
# v_list = [v_list[2]]
# v_list = ["visdrone/videos/vis_171"]
high = 30
tile = 16
# model_name = f"COCO_full_normalizedsaliency_R_101_FPN_crossthresh"
"""
For object detection, use bound 0.5, conv 9 for drone videos and dashcam videos.
Use
COCO_full_normalizedsaliency_R_101_FPN_crossthresh
as the model, and use
["dashcam/dashcam_%d" % i for i in range(1, 8)]
and
["visdrone/videos/vis_%d" % i for i in range(169, 174)]
for video id
"""
# conv_list = [3]
# bound_list = [0.05]
#
# for visdrone
# conv_list = [11]
# bound_list = [0.1]
# uniform color background
# conv_list = [1, 5, 9]
# bound_list = [0.15, 0.2, 0.25]
# base_list = [40, 36]
# conv_list = [1, 5]
# bound_list = [0.15, 0.1]
# base_list = [36]
conv_list = [1]
lb_list = [0.01, 0.007]
ub_list = [0.1, 0.05]
base_list = [36]
# conv_list = [1]
# bound_list = [0.2]
# base_list = [40]
# conv_list = [1, 5]
# bound_list = [0.1, 0.15, 0.05]
# base_list = [-1]
# model_name = f"cityscape_detection_FPN_SSD_withconfidence_allclasses_new_unfreezebackbone"
v_list = [
# "visdrone/videos/vis_%d" % i
# for i in range(169, 174)
"visdrone_new/drone_%d" % i
for i in range(7)
# "dashcam/dashcamcropped_%d" % i
# for i in range(1, 11)
]
# FPN
stats = "frozen_stats_MLSys/stats_QP30_thresh8_visdrone_FPN"
conf_thresh = 0.8
gt_conf_thresh = 0.8
app_name = "COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml"
# # efficientdet
# stats = "frozen_stats_MLSys/stats_QP30_thresh4_dashcamcropped_EfficientDet"
# conf_thresh = 0.4
# gt_conf_thresh = 0.4
# app_name = "EfficientDet"
model_app = "FPN"
model_name = f"COCO_detection_{model_app}_SSD_withconfidence_allclasses_new_unfreezebackbone_withoutclasscheck"
visualize_step_size = 300
# accs = [filter([fmt % i, "newSSDwconf", "bound_0.2", "lq_40", "conv_1"]) for i in ids]
import glob
# app_name = "Segmentation/fcn_resnet50"
# app_name = "EfficientDet"
filename = "SSD/accmpegmodel"
for conv, lb, ub, base, v in product(
conv_list, lb_list, ub_list, base_list, v_list
):
# output = f'{v}_compressed_ground_truth_2%_tile_16.mp4'
# visdrone/videos/vis_169_blackgen_bound_0.2_qp_30_conv_5_app_FPN.mp4
# output = f"{v}_blackgen_bound_{bound}_qp_30_conv_{conv}_app_FPN.mp4"
output = f"{v}_roi_lb_{lb}_ub_{ub}_conv_{conv}_hq_{high}_lq_{base}_app_{model_app}.mp4"
# examine_output = (
# f"{v}_blackgen_dual_SSD_bound_{bound}_conv_{conv}_app_FPN.mp4"
# )
# os.system(f"rm -r {examine_output}*")
if True:
os.system(
f"python compress_blackgen_roi_2bound.py -i {v}_qp_{high}.mp4 "
f" {v}_qp_{high}.mp4 -s {v} -o {output} --tile_size {tile} -p maskgen_pths/{model_name}.pth.best"
f" --conv_size {conv} "
f" -g {v}_qp_{high}.mp4 --lb {lb} --ub {ub} --hq {high} --lq {base} --smooth_frames 30 --app {app_name} "
f"--maskgen_file /tank/kuntai/code/video-compression/maskgen/{filename}.py --visualize_step_size {visualize_step_size} "
f"--upsample"
)
os.system(
f"python inference.py -i {output} --app {app_name} --confidence_threshold {conf_thresh} --gt_confidence_threshold {gt_conf_thresh} --visualize_step_size {visualize_step_size} "
f" --visualize --lq_result {v}_qp_{base}.mp4 --ground_truth {v}_qp_{high}.mp4"
)
os.system(f"rm -r {output}.pngs")
os.system(
f"python examine.py -i {output} -g {v}_qp_{high}.mp4 --confidence_threshold {conf_thresh} --gt_confidence_threshold {gt_conf_thresh} --app {app_name} --stats {stats}"
)
# if not os.path.exists(f"diff/{output}.gtdiff.mp4"):
# gt_output = f"{v}_compressed_blackgen_gt_bbox_conv_{conv}.mp4"
# subprocess.run(
# [
# "python",
# "diff.py",
# "-i",
# output,
# gt_output,
# "-o",
# f"diff/{output}.gtdiff.mp4",
# ]
# )