-
Notifications
You must be signed in to change notification settings - Fork 6
/
batch_blackgen.py
150 lines (123 loc) · 4.81 KB
/
batch_blackgen.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
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 = [
# "visdrone/videos/vis_%d" % i
# for i in range(169, 174)
# "dashcam/dashcam_2",
# "large_object/large_%d" % i
# for i in range(3, 5)
# "visdrone/videos/vis_172",
# "dashcam/dashcam_2_short",
# "dashcam/dashcam_8"
# "videos/trafficcam/trafficcam_1"
"dashcam/dashcamcropped_%d_downsampled" % i
for i in range(1, 11)
# "yoda/yoda_%d" % i
# for i in range(1, 9)
# "dashcam/dashcamcropped_%d" % i
# for i in [1, 2, 3, 4, 6, 7]
# "dashcam/dashcam_2"
# "visdrone/videos/vis_170",
# "visdrone/videos/vis_173",
# "visdrone/videos/vis_169",
# "visdrone/videos/vis_172",
# "visdrone/videos/vis_209",
# "visdrone/videos/vis_217",
] # + ["dashcam/dashcam_%d" % i for i in range(1, 11)]
# 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]
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"
model_name = "COCO_detection_FPN_SSD_withconfidence_allclasses_new_unfreezebackbone_withoutclasscheck"
stats = "stats_FPN_QP30_thresh7_prevframe_dashcamcropped_downsampled_dist"
conf_thresh = 0.7
gt_conf_thresh = 0.7
visualize_step_size = 20
# 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 = "COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml"
# app_name = "EfficientDet"
filename = "SSD/accmpegmodel"
for conv, bound, base, v in product(conv_list, bound_list, base_list, v_list):
print(v, conv, bound, base)
# 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}_blackgen_dual_thresh7_bound_{bound}_conv_{conv}_hq_{high}_lq_{base}_app_FPN.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"rm -r {output}*")
# os.system(
# f"python compress_blackgen.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 --bound {bound} --hq {high} --lq {base} --smooth_frames 1 --app {app_name} "
# f"--maskgen_file /tank/kuntai/code/video-compression/maskgen/{filename}.py --visualize_step_size {visualize_step_size}"
# )
os.system(
f"python inference_dist.py -i {output} --app {app_name} --confidence_threshold {conf_thresh} --gt_confidence_threshold {gt_conf_thresh} -g {v}_qp_{high}.mp4 --visualize_step_size {visualize_step_size} --lq_result {v}_qp_{base}.mp4"
)
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",
# ]
# )