Helios1208 commited on
Commit
53acdf8
·
verified ·
1 Parent(s): 2b770a9

Upload 3 files

Browse files
Files changed (3) hide show
  1. play_video.py +158 -0
  2. quality_check.py +354 -0
  3. viewer_app_win.py +189 -0
play_video.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+ import subprocess
4
+ import gradio as gr
5
+
6
+ CI_VID_DIR = "ci_vid_SC_test"
7
+ CACHE_DIR = "play_video/merged_previews"
8
+
9
+ FFMPEG_PATH = r"D:\ffmpeg-8.0.1-essentials_build\bin\ffmpeg.exe"
10
+
11
+ os.makedirs(CACHE_DIR, exist_ok=True)
12
+
13
+ def scan_data():
14
+ data_map = {}
15
+ if not os.path.exists(CI_VID_DIR): return data_map
16
+ for cp in sorted(glob.glob(os.path.join(CI_VID_DIR, "chunk_*"))):
17
+ chunk = os.path.basename(cp)
18
+ data_map[chunk] = {}
19
+ for vp in sorted(glob.glob(os.path.join(cp, "*"))):
20
+ if not os.path.isdir(vp): continue
21
+ vid = os.path.basename(vp)
22
+ data_map[chunk][vid] = {}
23
+ for cmp in sorted(glob.glob(os.path.join(vp, "*"))):
24
+ if not os.path.isdir(cmp): continue
25
+ cam = os.path.basename(cmp)
26
+ shots = sorted(
27
+ [os.path.basename(f).replace('.mp4', '') for f in glob.glob(os.path.join(cmp, "*.mp4")) if os.path.basename(f).replace('.mp4', '').isdigit()],
28
+ key=lambda x: int(x)
29
+ )
30
+ if shots:
31
+ data_map[chunk][vid][cam] = shots
32
+ return data_map
33
+
34
+ DATA_MAP = scan_data()
35
+
36
+ def get_init():
37
+ c = list(DATA_MAP.keys())[0] if DATA_MAP else "-"
38
+ v = list(DATA_MAP.get(c, {}).keys())[0] if DATA_MAP.get(c) else "-"
39
+ cam = list(DATA_MAP.get(c, {}).get(v, {}).keys())[0] if DATA_MAP.get(c, {}).get(v) else "-"
40
+ return list(DATA_MAP.keys()), c, list(DATA_MAP.get(c, {}).keys()), v, list(DATA_MAP.get(c, {}).get(v, {}).keys()), cam
41
+
42
+ CHUNKS, C, VIDS, V, CAMS, CAM = get_init()
43
+
44
+ def get_choices_and_val(lst):
45
+ return gr.update(choices=lst, value=lst[0] if lst else "-")
46
+
47
+ # 【新增】确保视频为H.264格式并缓存
48
+ def ensure_h264_cache(orig_path, chunk, vid, cam, shot_name):
49
+ if not orig_path: return None
50
+
51
+ # 构造缓存路径
52
+ out_name = f"h264_orig_{chunk}_{vid}_{cam}_{shot_name}.mp4"
53
+ out_path = os.path.join(CACHE_DIR, out_name)
54
+
55
+ # 如果已经转码过了,直接返回,秒开
56
+ if os.path.exists(out_path):
57
+ return out_path
58
+
59
+ # 如果没转过,用 FFmpeg 快速转码为 H.264
60
+ cmd = [
61
+ FFMPEG_PATH, '-y', '-i', orig_path,
62
+ '-c:v', 'libx264', '-preset', 'ultrafast', '-crf', '28',
63
+ '-c:a', 'copy', out_path
64
+ ]
65
+ subprocess.run(cmd, capture_output=True)
66
+
67
+ return out_path if os.path.exists(out_path) else None
68
+
69
+ def update_4_shots(chunk, vid, cam):
70
+ if "-" in [chunk, vid, cam]:
71
+ return [None, None, None, None]
72
+
73
+ search_path = os.path.join(CI_VID_DIR, chunk, vid, cam, "*.mp4")
74
+ shots = sorted(
75
+ [p for p in glob.glob(search_path) if os.path.basename(p).replace('.mp4','').isdigit()],
76
+ key=lambda x: int(os.path.basename(x).split('.')[0])
77
+ )
78
+
79
+ out = []
80
+ for i in range(4):
81
+ if i < len(shots):
82
+ # 获取原始视频路径,并通过转码函数拿到 H.264 版本的缓存路径
83
+ orig_path = shots[i]
84
+ shot_name = os.path.basename(orig_path).replace('.mp4', '')
85
+ safe_path = ensure_h264_cache(orig_path, chunk, vid, cam, shot_name)
86
+ out.append(safe_path)
87
+ else:
88
+ out.append(None)
89
+ return out
90
+
91
+ def chunk_update(chunk):
92
+ vids = list(DATA_MAP.get(chunk, {}).keys())
93
+ v_def = vids[0] if vids else "-"
94
+ cams = list(DATA_MAP.get(chunk, {}).get(v_def, {}).keys())
95
+ c_def = cams[0] if cams else "-"
96
+
97
+ s1, s2, s3, s4 = update_4_shots(chunk, v_def, c_def)
98
+ return get_choices_and_val(vids), get_choices_and_val(cams), s1, s2, s3, s4
99
+
100
+ def vid_update(chunk, vid):
101
+ cams = list(DATA_MAP.get(chunk, {}).get(vid, {}).keys())
102
+ c_def = cams[0] if cams else "-"
103
+
104
+ s1, s2, s3, s4 = update_4_shots(chunk, vid, c_def)
105
+ return get_choices_and_val(cams), s1, s2, s3, s4
106
+
107
+ def cam_update(chunk, vid, cam):
108
+ s1, s2, s3, s4 = update_4_shots(chunk, vid, cam)
109
+ return s1, s2, s3, s4
110
+
111
+ def concat_original_shots(chunk, vid, cam):
112
+ if "-" in [chunk, vid, cam]: return None
113
+ paths = update_4_shots(chunk, vid, cam)
114
+ inputs = [p for p in paths if p is not None]
115
+ if not inputs: return None
116
+
117
+ out_path = os.path.join(CACHE_DIR, f"concat_orig_{chunk}_{vid}_{cam}.mp4")
118
+ if os.path.exists(out_path):
119
+ return out_path
120
+
121
+ flt = "".join([f"[{i}:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=24[v{i}];" for i in range(len(inputs))])
122
+ concat = "".join([f"[v{i}]" for i in range(len(inputs))]) + f"concat=n={len(inputs)}:v=1:a=0[outv]"
123
+ cmd = [FFMPEG_PATH, "-y", *sum([["-i", inp] for inp in inputs], []), "-filter_complex", flt + concat, "-map", "[outv]", "-c:v", "libx264", "-preset", "ultrafast", out_path]
124
+ subprocess.run(cmd, check=True, capture_output=True)
125
+
126
+ return out_path
127
+
128
+ with gr.Blocks() as app:
129
+ gr.Markdown("# 🎬 原始序列视频拼接与查看器")
130
+
131
+ with gr.Row():
132
+ chunk_dd = gr.Dropdown(choices=CHUNKS, label="1. Chunk", value=C)
133
+ vid_dd = gr.Dropdown(choices=VIDS, label="2. Video ID", value=V)
134
+ cam_dd = gr.Dropdown(choices=CAMS, label="3. Camera ID", value=CAM)
135
+
136
+ gr.Markdown("---")
137
+ gr.Markdown("### 🎥 原始 Shot 预览 (按顺序自动加载,最多展示4个)")
138
+ with gr.Row():
139
+ shot_vids = [gr.Video(label=f"Shot {i+1}") for i in range(4)]
140
+
141
+ gr.Markdown("---")
142
+ with gr.Row():
143
+ btn_concat_orig = gr.Button("🔗 拼接以上原始视频", variant="primary")
144
+ v_orig_concat = gr.Video(label="拼接结果")
145
+
146
+ chunk_dd.change(chunk_update, [chunk_dd], [vid_dd, cam_dd] + shot_vids)
147
+ vid_dd.change(vid_update, [chunk_dd, vid_dd], [cam_dd] + shot_vids)
148
+ cam_dd.change(cam_update, [chunk_dd, vid_dd, cam_dd], shot_vids)
149
+
150
+ btn_concat_orig.click(concat_original_shots, [chunk_dd, vid_dd, cam_dd], [v_orig_concat])
151
+
152
+ app.load(lambda c, v, cam: tuple(update_4_shots(c, v, cam)), [chunk_dd, vid_dd, cam_dd], shot_vids)
153
+
154
+ if __name__ == "__main__":
155
+ print(f"Link: http://127.0.0.1:7860/")
156
+ # 放开限制
157
+ allowed = [os.path.abspath(CI_VID_DIR).replace("\\", "/"), os.path.abspath(CACHE_DIR).replace("\\", "/"), "/workspace", os.path.abspath(".")]
158
+ app.launch(server_name="0.0.0.0", server_port=7860, share=True, allowed_paths=allowed)
quality_check.py ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+ import subprocess
4
+ import gradio as gr
5
+ import cv2
6
+ import numpy as np
7
+ import json
8
+
9
+ STAGE3_DIR = "test_removal_0_39/stage3_prop_masks"
10
+ STAGE4_DIR = "test_removal_0_39/stage4_inpainted"
11
+ CI_VID_DIR = "ci_vid_SC_test"
12
+ CACHE_DIR = "outputs/merged_previews"
13
+ ANNOTATION_FILE = "removal_annotations.json"
14
+
15
+ FFMPEG_PATH = r"D:\ffmpeg-8.0.1-essentials_build\bin\ffmpeg.exe"
16
+
17
+ os.makedirs(CACHE_DIR, exist_ok=True)
18
+
19
+ # ======================= 【层级化 JSON 读写逻辑】 =======================
20
+ def load_annotations():
21
+ """读取层级化 JSON 标注记录"""
22
+ if os.path.exists(ANNOTATION_FILE):
23
+ try:
24
+ with open(ANNOTATION_FILE, mode='r', encoding='utf-8') as f:
25
+ return json.load(f)
26
+ except Exception:
27
+ return {}
28
+ return {}
29
+
30
+ def save_annotation(chunk, vid, cam, shot, obj, rating):
31
+ """保存标注到层级化 JSON 文件"""
32
+ if not rating:
33
+ return "⚠️ Please select a rating first!"
34
+ if "-" in [chunk, vid, cam, shot, obj]:
35
+ return "⚠️ Please select a valid clip!"
36
+
37
+ anns = load_annotations()
38
+
39
+ if chunk not in anns: anns[chunk] = {}
40
+ if vid not in anns[chunk]: anns[chunk][vid] = {}
41
+ if cam not in anns[chunk][vid]: anns[chunk][vid][cam] = {}
42
+ if shot not in anns[chunk][vid][cam]: anns[chunk][vid][cam][shot] = {}
43
+
44
+ anns[chunk][vid][cam][shot][obj] = rating
45
+
46
+ with open(ANNOTATION_FILE, mode='w', encoding='utf-8') as f:
47
+ json.dump(anns, f, ensure_ascii=False, indent=4)
48
+
49
+ return f"✅ Saved: `{obj}` marked as **{rating}**"
50
+
51
+ def sync_annotation_ui(chunk, vid, cam, shot, obj):
52
+ """同步 UI 状态 (安全地从嵌套字典中读取)"""
53
+ anns = load_annotations()
54
+ current_rating = anns.get(chunk, {}).get(vid, {}).get(cam, {}).get(shot, {}).get(obj, None)
55
+ return gr.update(value=current_rating), ""
56
+ # =====================================================================
57
+
58
+
59
+ def scan_data():
60
+ data_map = {}
61
+ if not os.path.exists(STAGE4_DIR): return data_map
62
+ for cp in sorted(glob.glob(os.path.join(STAGE4_DIR, "chunk_*"))):
63
+ chunk = os.path.basename(cp)
64
+ data_map[chunk] = {}
65
+ for vp in sorted(glob.glob(os.path.join(cp, "*"))):
66
+ if not os.path.isdir(vp): continue
67
+ vid = os.path.basename(vp)
68
+ data_map[chunk][vid] = {}
69
+ for cmp in sorted(glob.glob(os.path.join(vp, "*"))):
70
+ if not os.path.isdir(cmp): continue
71
+ cam = os.path.basename(cmp)
72
+ data_map[chunk][vid][cam] = {}
73
+ for sp in sorted(glob.glob(os.path.join(cmp, "*"))):
74
+ if not os.path.isdir(sp): continue
75
+ shot = os.path.basename(sp)
76
+ if not shot.isdigit(): continue
77
+ objs = [os.path.basename(o).replace('.mp4', '') for o in glob.glob(os.path.join(sp, "*.mp4"))]
78
+ if objs: data_map[chunk][vid][cam][shot] = sorted(objs)
79
+ return data_map
80
+
81
+ ORIGINAL_DATA_MAP = scan_data()
82
+
83
+ def get_init(data_map):
84
+ c = list(data_map.keys())[0] if data_map else "-"
85
+ v = list(data_map.get(c, {}).keys())[0] if data_map.get(c) else "-"
86
+ cam = list(data_map.get(c, {}).get(v, {}).keys())[0] if data_map.get(c, {}).get(v) else "-"
87
+ s = list(data_map.get(c, {}).get(v, {}).get(cam, {}).keys())[0] if data_map.get(c, {}).get(v, {}).get(cam) else "-"
88
+ o = data_map.get(c, {}).get(v, {}).get(cam, {}).get(s, [])[0] if data_map.get(c, {}).get(v, {}).get(cam, {}).get(s) else "-"
89
+ return list(data_map.keys()), c, list(data_map.get(c, {}).keys()), v, list(data_map.get(c, {}).get(v, {}).keys()), cam, list(data_map.get(c, {}).get(v, {}).get(cam, {}).keys()), s, data_map.get(c, {}).get(v, {}).get(cam, {}).get(s, []), o
90
+
91
+
92
+ # ======================= 【新增】动态计数与刷新逻辑 =======================
93
+ def get_filter_choices_and_val(base_filter="All"):
94
+ """计算各标签的数量,并生成带数字的 Radio 选项"""
95
+ anns = load_annotations()
96
+ counts = {"All": 0, "Unlabeled": 0, "High": 0, "Medium": 0, "Low": 0}
97
+
98
+ for c, v_dict in ORIGINAL_DATA_MAP.items():
99
+ for v, cam_dict in v_dict.items():
100
+ for cam, s_dict in cam_dict.items():
101
+ for s, o_list in s_dict.items():
102
+ for o in o_list:
103
+ counts["All"] += 1
104
+ val = anns.get(c, {}).get(v, {}).get(cam, {}).get(s, {}).get(o, "")
105
+ if not val:
106
+ counts["Unlabeled"] += 1
107
+ elif val in counts:
108
+ counts[val] += 1
109
+
110
+ choices = [
111
+ f"All ({counts['All']})",
112
+ f"Unlabeled ({counts['Unlabeled']})",
113
+ f"High ({counts['High']})",
114
+ f"Medium ({counts['Medium']})",
115
+ f"Low ({counts['Low']})"
116
+ ]
117
+
118
+ # 找到当前应该选中的那个项 (模糊匹配前缀)
119
+ current_val = choices[0]
120
+ for choice in choices:
121
+ if choice.startswith(base_filter):
122
+ current_val = choice
123
+ break
124
+
125
+ return choices, current_val
126
+
127
+ def apply_filter(base_filter):
128
+ """基于纯净标签 (如 'All') 进行过滤"""
129
+ if base_filter == "All":
130
+ return ORIGINAL_DATA_MAP
131
+
132
+ anns = load_annotations()
133
+ filtered = {}
134
+ for c, v_dict in ORIGINAL_DATA_MAP.items():
135
+ for v, cam_dict in v_dict.items():
136
+ for cam, s_dict in cam_dict.items():
137
+ for s, o_list in s_dict.items():
138
+ valid_objs = []
139
+ for o in o_list:
140
+ val = anns.get(c, {}).get(v, {}).get(cam, {}).get(s, {}).get(o, "")
141
+ if base_filter == "Unlabeled" and not val:
142
+ valid_objs.append(o)
143
+ elif val == base_filter:
144
+ valid_objs.append(o)
145
+
146
+ if valid_objs:
147
+ if c not in filtered: filtered[c] = {}
148
+ if v not in filtered[c]: filtered[c][v] = {}
149
+ if cam not in filtered[c][v]: filtered[c][v][cam] = {}
150
+ filtered[c][v][cam][s] = valid_objs
151
+ return filtered
152
+
153
+ def refresh_ui(current_filter_label):
154
+ """统一的刷新事件入口:重新统计数字 -> 重新过滤数据树 -> 刷新所有 UI"""
155
+ # 提取纯净标签 (把 "Unlabeled (42)" 截取成 "Unlabeled")
156
+ base_filter = "All" if not current_filter_label else current_filter_label.split(" ")[0]
157
+
158
+ choices, new_radio_val = get_filter_choices_and_val(base_filter)
159
+ filtered_map = apply_filter(base_filter)
160
+
161
+ _, c, _, v, _, cam, _, s, _, o = get_init(filtered_map)
162
+
163
+ c_list = list(filtered_map.keys())
164
+ v_list = list(filtered_map.get(c, {}).keys()) if c != "-" else []
165
+ cam_list = list(filtered_map.get(c, {}).get(v, {}).keys()) if v != "-" else []
166
+ s_list = list(filtered_map.get(c, {}).get(v, {}).get(cam, {}).keys()) if cam != "-" else []
167
+ o_list = filtered_map.get(c, {}).get(v, {}).get(cam, {}).get(s, []) if s != "-" else []
168
+ vr = get_valid_replace_shots(filtered_map, c, v, cam, o)
169
+
170
+ return (
171
+ filtered_map,
172
+ gr.update(choices=choices, value=new_radio_val), # 更新带有最新数字的选项
173
+ get_choices_and_val(c_list),
174
+ get_choices_and_val(v_list),
175
+ get_choices_and_val(cam_list),
176
+ get_choices_and_val(s_list),
177
+ get_choices_and_val(o_list),
178
+ gr.update(choices=vr, value=vr if vr else "-", label=f"Use replacement clips for [{o if o!='-' else 'None'}]")
179
+ )
180
+ # =====================================================================
181
+
182
+ def get_choices_and_val(lst):
183
+ return gr.update(choices=lst, value=lst[0] if lst else "-")
184
+
185
+ def get_valid_replace_shots(data_map, chunk, vid, cam, obj):
186
+ if "-" in [chunk, vid, cam, obj]: return []
187
+ return [s for s in list(data_map.get(chunk, {}).get(vid, {}).get(cam, {}).keys()) if obj in data_map.get(chunk, {}).get(vid, {}).get(cam, {}).get(s, [])]
188
+
189
+ def chunk_update(state_map, chunk):
190
+ vids = list(state_map.get(chunk, {}).keys())
191
+ cams = list(state_map.get(chunk, {}).get(vids[0] if vids else "-", {}).keys())
192
+ shots = list(state_map.get(chunk, {}).get(vids[0] if vids else "-", {}).get(cams[0] if cams else "-", {}).keys())
193
+ objs = state_map.get(chunk, {}).get(vids[0] if vids else "-", {}).get(cams[0] if cams else "-", {}).get(shots[0] if shots else "-", [])
194
+ vr = get_valid_replace_shots(state_map, chunk, vids[0] if vids else "-", cams[0] if cams else "-", objs[0] if objs else "-")
195
+ return get_choices_and_val(vids), get_choices_and_val(cams), get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"Use replacement clips for [{objs[0] if objs else '-'}]")
196
+
197
+ def vid_update(state_map, chunk, vid):
198
+ cams = list(state_map.get(chunk, {}).get(vid, {}).keys())
199
+ shots = list(state_map.get(chunk, {}).get(vid, {}).get(cams[0] if cams else "-", {}).keys())
200
+ objs = state_map.get(chunk, {}).get(vid, {}).get(cams[0] if cams else "-", {}).get(shots[0] if shots else "-", [])
201
+ vr = get_valid_replace_shots(state_map, chunk, vid, cams[0] if cams else "-", objs[0] if objs else "-")
202
+ return get_choices_and_val(cams), get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"Use replacement clips for [{objs[0] if objs else '-'}]")
203
+
204
+ def cam_update(state_map, chunk, vid, cam):
205
+ shots = list(state_map.get(chunk, {}).get(vid, {}).get(cam, {}).keys())
206
+ objs = state_map.get(chunk, {}).get(vid, {}).get(cam, {}).get(shots[0] if shots else "-", [])
207
+ vr = get_valid_replace_shots(state_map, chunk, vid, cam, objs[0] if objs else "-")
208
+ return get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"Use replacement clips for [{objs[0] if objs else '-'}]")
209
+
210
+ def shot_update(state_map, chunk, vid, cam, shot):
211
+ objs = state_map.get(chunk, {}).get(vid, {}).get(cam, {}).get(shot, [])
212
+ vr = get_valid_replace_shots(state_map, chunk, vid, cam, objs[0] if objs else "-")
213
+ return get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"Use replacement clips for [{objs[0] if objs else '-'}]")
214
+
215
+ def obj_update(state_map, chunk, vid, cam, obj):
216
+ vr = get_valid_replace_shots(state_map, chunk, vid, cam, obj)
217
+ return gr.update(choices=vr, value=vr, label=f"Use replacement clips for [{obj}]")
218
+
219
+ def create_overlay_video(orig_path, mask_dir, out_path):
220
+ if os.path.exists(out_path): return out_path
221
+
222
+ cap = cv2.VideoCapture(orig_path)
223
+ fps = cap.get(cv2.CAP_PROP_FPS) or 24
224
+ orig_w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
225
+ orig_h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
226
+
227
+ scale = 0.5
228
+ w = int((orig_w * scale) // 2 * 2)
229
+ h = int((orig_h * scale) // 2 * 2)
230
+
231
+ mask_files = sorted(glob.glob(os.path.join(mask_dir, "*.png")))
232
+ temp_path = out_path.replace('.mp4', '_temp.mp4')
233
+ out = cv2.VideoWriter(temp_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
234
+
235
+ idx = 0
236
+ while True:
237
+ ret, frame = cap.read()
238
+ if not ret: break
239
+
240
+ frame = cv2.resize(frame, (w, h), interpolation=cv2.INTER_AREA)
241
+ if idx < len(mask_files):
242
+ mask = cv2.imread(mask_files[idx], cv2.IMREAD_GRAYSCALE)
243
+ if mask is not None:
244
+ mask = cv2.resize(mask, (w, h), interpolation=cv2.INTER_NEAREST)
245
+ frame[mask > 128] = frame[mask > 128] * 0.5 + np.array([0, 0, 255], dtype=np.uint8) * 0.5
246
+ out.write(frame)
247
+ idx += 1
248
+
249
+ cap.release()
250
+ out.release()
251
+
252
+ subprocess.run([FFMPEG_PATH, '-y', '-i', temp_path, '-c:v', 'libx264', '-preset', 'ultrafast', '-crf', '32', out_path], capture_output=True)
253
+ if os.path.exists(temp_path): os.remove(temp_path)
254
+ return out_path
255
+
256
+ def load_preview(chunk, vid, cam, shot, obj):
257
+ if not all([chunk, vid, cam, shot, obj]) or "-" in [chunk, vid, cam, shot, obj]: return None, None
258
+ orig = os.path.join(CI_VID_DIR, chunk, vid, cam, f"{shot}.mp4")
259
+ edit = os.path.join(STAGE4_DIR, chunk, vid, cam, str(shot), f"{obj}.mp4")
260
+ mask_dir = os.path.join(STAGE3_DIR, chunk, vid, cam, str(shot), str(obj))
261
+ orig_to_show = create_overlay_video(orig, mask_dir, os.path.join(CACHE_DIR, f"ov_{chunk}_{vid}_{cam}_{shot}_{obj}.mp4")) if os.path.exists(orig) and os.path.exists(mask_dir) else (orig if os.path.exists(orig) else None)
262
+ return orig_to_show, (edit if os.path.exists(edit) else None)
263
+
264
+ def merge_videos(chunk, vid, cam, obj, replace_shots):
265
+ if not all([chunk, vid, cam, obj]) or "-" in [chunk, vid, cam, obj]: return None
266
+ all_orig = sorted([p for p in glob.glob(os.path.join(CI_VID_DIR, chunk, vid, cam, "*.mp4")) if os.path.basename(p).replace('.mp4','').isdigit()], key=lambda x: int(os.path.basename(x).split('.')[0]))
267
+ out_path = os.path.join(CACHE_DIR, f"merged_{chunk}_{vid}_{cam}_{obj}.mp4")
268
+ inputs = []
269
+ for p in all_orig:
270
+ sid = os.path.basename(p).replace('.mp4','')
271
+ edit_p = os.path.join(STAGE4_DIR, chunk, vid, cam, sid, f"{obj}.mp4")
272
+ inputs.append(edit_p if (sid in replace_shots and os.path.exists(edit_p)) else p)
273
+ if not inputs: return None
274
+ flt = "".join([f"[{i}:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=24[v{i}];" for i in range(len(inputs))])
275
+ concat = "".join([f"[v{i}]" for i in range(len(inputs))]) + f"concat=n={len(inputs)}:v=1:a=0[outv]"
276
+ cmd = [FFMPEG_PATH, "-y", *sum([["-i", inp] for inp in inputs], []), "-filter_complex", flt + concat, "-map", "[outv]", "-c:v", "libx264", "-preset", "ultrafast", out_path]
277
+ subprocess.run(cmd, check=True, capture_output=True)
278
+ return out_path
279
+
280
+ # 获取初始标签和数字
281
+ INIT_CHOICES, INIT_VAL = get_filter_choices_and_val("All")
282
+ CHUNKS, C, VIDS, V, CAMS, CAM, SHOTS, S, OBJS, O = get_init(ORIGINAL_DATA_MAP)
283
+
284
+ with gr.Blocks() as app:
285
+ state_map = gr.State(ORIGINAL_DATA_MAP)
286
+
287
+ gr.Markdown("# 🎬 Inconsistency Quality Check Panel")
288
+
289
+ with gr.Row(variant="panel"):
290
+ filter_radio = gr.Radio(
291
+ choices=INIT_CHOICES,
292
+ value=INIT_VAL,
293
+ label="🔎 Filter Status"
294
+ )
295
+
296
+ with gr.Row():
297
+ chunk_dd = gr.Dropdown(choices=CHUNKS, label="1. Chunk", value=C)
298
+ vid_dd = gr.Dropdown(choices=VIDS, label="2. Video ID", value=V)
299
+ cam_dd = gr.Dropdown(choices=CAMS, label="3. Camera ID", value=CAM)
300
+ gr.Markdown("---")
301
+ with gr.Row():
302
+ with gr.Column():
303
+ with gr.Row():
304
+ shot_dd = gr.Dropdown(choices=SHOTS, label="4. Shot", value=S)
305
+ obj_dd = gr.Dropdown(choices=OBJS, label="5. Object", value=O)
306
+
307
+ gr.Markdown("### ✍️ Evaluation")
308
+ with gr.Row(variant="panel"):
309
+ rating_radio = gr.Radio(choices=["High", "Medium", "Low"], label="6. Rate Removal Quality")
310
+ with gr.Column():
311
+ save_btn = gr.Button("💾 Save Rating", variant="primary")
312
+ refresh_btn = gr.Button("🔄 Refresh List & Stats", variant="secondary") # 【新增刷新按钮】
313
+ save_status = gr.Markdown("")
314
+
315
+ v_orig = gr.Video(label="Original w/ Mask")
316
+ v_edit = gr.Video(label="Inpainted Result")
317
+
318
+ with gr.Column():
319
+ replace = gr.CheckboxGroup(choices=get_valid_replace_shots(ORIGINAL_DATA_MAP, C, V, CAM, O), label=f"Use replacement clips for [{O}]", value=get_valid_replace_shots(ORIGINAL_DATA_MAP, C, V, CAM, O))
320
+ btn = gr.Button("🚀 Generate Sequence Preview", variant="secondary")
321
+ v_res = gr.Video(label="Sequence Preview")
322
+
323
+ # ================= 绑定事件 =================
324
+
325
+ # 0. 刷新按钮 与 筛选器 共用同一套更新逻辑
326
+ refresh_outputs = [state_map, filter_radio, chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd, replace]
327
+ filter_radio.change(refresh_ui, [filter_radio], refresh_outputs)
328
+ refresh_btn.click(refresh_ui, [filter_radio], refresh_outputs)
329
+
330
+ # 1. 列表联级更新 (毫秒级)
331
+ chunk_dd.change(chunk_update, [state_map, chunk_dd], [vid_dd, cam_dd, shot_dd, obj_dd, replace])
332
+ vid_dd.change(vid_update, [state_map, chunk_dd, vid_dd], [cam_dd, shot_dd, obj_dd, replace])
333
+ cam_dd.change(cam_update, [state_map, chunk_dd, vid_dd, cam_dd], [shot_dd, obj_dd, replace])
334
+ shot_dd.change(shot_update, [state_map, chunk_dd, vid_dd, cam_dd, shot_dd], [obj_dd, replace])
335
+ obj_dd.change(obj_update, [state_map, chunk_dd, vid_dd, cam_dd, obj_dd], [replace])
336
+
337
+ # 2. 优先刷新 UI 状态 (毫秒级)
338
+ shot_dd.change(sync_annotation_ui, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [rating_radio, save_status])
339
+ obj_dd.change(sync_annotation_ui, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [rating_radio, save_status])
340
+ app.load(sync_annotation_ui, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [rating_radio, save_status])
341
+
342
+ save_btn.click(save_annotation, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd, rating_radio], [save_status])
343
+
344
+ # 3. 最后加载视频 (耗时)
345
+ shot_dd.change(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
346
+ obj_dd.change(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
347
+ app.load(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
348
+
349
+ # 合成全序列视频
350
+ btn.click(merge_videos, [chunk_dd, vid_dd, cam_dd, obj_dd, replace], [v_res])
351
+
352
+ if __name__ == "__main__":
353
+ print(f"Link: http://127.0.0.1:7860/")
354
+ app.launch(server_name="0.0.0.0", server_port=7860)
viewer_app_win.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+ import subprocess
4
+ import gradio as gr
5
+ import cv2
6
+ import numpy as np
7
+
8
+ STAGE3_DIR = "test_removal_0_39/stage3_prop_masks"
9
+ STAGE4_DIR = "test_removal_0_39/stage4_inpainted"
10
+ CI_VID_DIR = "ci_vid_SC_test"
11
+ CACHE_DIR = "outputs/merged_previews"
12
+
13
+ FFMPEG_PATH = r"D:\ffmpeg-8.0.1-essentials_build\bin\ffmpeg.exe"
14
+
15
+ os.makedirs(CACHE_DIR, exist_ok=True)
16
+
17
+ def scan_data():
18
+ data_map = {}
19
+ if not os.path.exists(STAGE4_DIR): return data_map
20
+ for cp in sorted(glob.glob(os.path.join(STAGE4_DIR, "chunk_*"))):
21
+ chunk = os.path.basename(cp)
22
+ data_map[chunk] = {}
23
+ for vp in sorted(glob.glob(os.path.join(cp, "*"))):
24
+ if not os.path.isdir(vp): continue
25
+ vid = os.path.basename(vp)
26
+ data_map[chunk][vid] = {}
27
+ for cmp in sorted(glob.glob(os.path.join(vp, "*"))):
28
+ if not os.path.isdir(cmp): continue
29
+ cam = os.path.basename(cmp)
30
+ data_map[chunk][vid][cam] = {}
31
+ for sp in sorted(glob.glob(os.path.join(cmp, "*"))):
32
+ if not os.path.isdir(sp): continue
33
+ shot = os.path.basename(sp)
34
+ if not shot.isdigit(): continue
35
+ objs = [os.path.basename(o).replace('.mp4', '') for o in glob.glob(os.path.join(sp, "*.mp4"))]
36
+ if objs: data_map[chunk][vid][cam][shot] = sorted(objs)
37
+ return data_map
38
+
39
+ DATA_MAP = scan_data()
40
+
41
+ def get_init():
42
+ c = list(DATA_MAP.keys())[0] if DATA_MAP else "-"
43
+ v = list(DATA_MAP.get(c, {}).keys())[0] if DATA_MAP.get(c) else "-"
44
+ cam = list(DATA_MAP.get(c, {}).get(v, {}).keys())[0] if DATA_MAP.get(c, {}).get(v) else "-"
45
+ s = list(DATA_MAP.get(c, {}).get(v, {}).get(cam, {}).keys())[0] if DATA_MAP.get(c, {}).get(v, {}).get(cam) else "-"
46
+ o = DATA_MAP.get(c, {}).get(v, {}).get(cam, {}).get(s, [])[0] if DATA_MAP.get(c, {}).get(v, {}).get(cam, {}).get(s) else "-"
47
+ return list(DATA_MAP.keys()), c, list(DATA_MAP.get(c, {}).keys()), v, list(DATA_MAP.get(c, {}).get(v, {}).keys()), cam, list(DATA_MAP.get(c, {}).get(v, {}).get(cam, {}).keys()), s, DATA_MAP.get(c, {}).get(v, {}).get(cam, {}).get(s, []), o
48
+
49
+ CHUNKS, C, VIDS, V, CAMS, CAM, SHOTS, S, OBJS, O = get_init()
50
+
51
+ def get_choices_and_val(lst):
52
+ return gr.update(choices=lst, value=lst[0] if lst else "-")
53
+
54
+ def get_valid_replace_shots(chunk, vid, cam, obj):
55
+ if "-" in [chunk, vid, cam, obj]: return []
56
+ return [s for s in list(DATA_MAP.get(chunk, {}).get(vid, {}).get(cam, {}).keys()) if obj in DATA_MAP.get(chunk, {}).get(vid, {}).get(cam, {}).get(s, [])]
57
+
58
+ def chunk_update(chunk):
59
+ vids = list(DATA_MAP.get(chunk, {}).keys())
60
+ cams = list(DATA_MAP.get(chunk, {}).get(vids[0] if vids else "-", {}).keys())
61
+ shots = list(DATA_MAP.get(chunk, {}).get(vids[0] if vids else "-", {}).get(cams[0] if cams else "-", {}).keys())
62
+ objs = DATA_MAP.get(chunk, {}).get(vids[0] if vids else "-", {}).get(cams[0] if cams else "-", {}).get(shots[0] if shots else "-", [])
63
+ vr = get_valid_replace_shots(chunk, vids[0] if vids else "-", cams[0] if cams else "-", objs[0] if objs else "-")
64
+ return get_choices_and_val(vids), get_choices_and_val(cams), get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"使用 [{objs[0] if objs else '-'}] 擦除版的片段")
65
+
66
+ def vid_update(chunk, vid):
67
+ cams = list(DATA_MAP.get(chunk, {}).get(vid, {}).keys())
68
+ shots = list(DATA_MAP.get(chunk, {}).get(vid, {}).get(cams[0] if cams else "-", {}).keys())
69
+ objs = DATA_MAP.get(chunk, {}).get(vid, {}).get(cams[0] if cams else "-", {}).get(shots[0] if shots else "-", [])
70
+ vr = get_valid_replace_shots(chunk, vid, cams[0] if cams else "-", objs[0] if objs else "-")
71
+ return get_choices_and_val(cams), get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"使用 [{objs[0] if objs else '-'}] 擦除版的片段")
72
+
73
+ def cam_update(chunk, vid, cam):
74
+ shots = list(DATA_MAP.get(chunk, {}).get(vid, {}).get(cam, {}).keys())
75
+ objs = DATA_MAP.get(chunk, {}).get(vid, {}).get(cam, {}).get(shots[0] if shots else "-", [])
76
+ vr = get_valid_replace_shots(chunk, vid, cam, objs[0] if objs else "-")
77
+ return get_choices_and_val(shots), get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"使用 [{objs[0] if objs else '-'}] 擦除版的片段")
78
+
79
+ def shot_update(chunk, vid, cam, shot):
80
+ objs = DATA_MAP.get(chunk, {}).get(vid, {}).get(cam, {}).get(shot, [])
81
+ vr = get_valid_replace_shots(chunk, vid, cam, objs[0] if objs else "-")
82
+ return get_choices_and_val(objs), gr.update(choices=vr, value=vr, label=f"使用 [{objs[0] if objs else '-'}] 擦除版的片段")
83
+
84
+ def obj_update(chunk, vid, cam, obj):
85
+ vr = get_valid_replace_shots(chunk, vid, cam, obj)
86
+ return gr.update(choices=vr, value=vr, label=f"使用 [{obj}] 擦除版的片段")
87
+
88
+ def create_overlay_video(orig_path, mask_dir, out_path):
89
+ if os.path.exists(out_path): return out_path
90
+
91
+ cap = cv2.VideoCapture(orig_path)
92
+ fps = cap.get(cv2.CAP_PROP_FPS) or 24
93
+ orig_w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
94
+ orig_h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
95
+
96
+ # 【新增优化】设置缩放比例为 0.5(长宽各减半)
97
+ scale = 0.5
98
+ # 【新增优化】确保新计算出的长宽必须是偶数 (H.264 编码器的硬性要求,否则会报错)
99
+ w = int((orig_w * scale) // 2 * 2)
100
+ h = int((orig_h * scale) // 2 * 2)
101
+
102
+ mask_files = sorted(glob.glob(os.path.join(mask_dir, "*.png")))
103
+ temp_path = out_path.replace('.mp4', '_temp.mp4')
104
+ out = cv2.VideoWriter(temp_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
105
+
106
+ idx = 0
107
+ while True:
108
+ ret, frame = cap.read()
109
+ if not ret: break
110
+
111
+ # 【新增优化】把原始视频帧缩小
112
+ frame = cv2.resize(frame, (w, h), interpolation=cv2.INTER_AREA)
113
+
114
+ if idx < len(mask_files):
115
+ mask = cv2.imread(mask_files[idx], cv2.IMREAD_GRAYSCALE)
116
+ if mask is not None:
117
+ # 把 Mask 也缩放到相同的小尺寸
118
+ mask = cv2.resize(mask, (w, h), interpolation=cv2.INTER_NEAREST)
119
+ frame[mask > 128] = frame[mask > 128] * 0.5 + np.array([0, 0, 255], dtype=np.uint8) * 0.5
120
+
121
+ out.write(frame)
122
+ idx += 1
123
+
124
+ cap.release()
125
+ out.release()
126
+
127
+ # 【优化参数】将 -crf 从 28 提高到 32(牺牲一点画质换取更快的编码速度)
128
+ # 注意这里默认你已经用了 FFMPEG_PATH 变量
129
+ subprocess.run([FFMPEG_PATH, '-y', '-i', temp_path, '-c:v', 'libx264', '-preset', 'ultrafast', '-crf', '32', out_path], capture_output=True)
130
+
131
+ if os.path.exists(temp_path): os.remove(temp_path)
132
+ return out_path
133
+ def load_preview(chunk, vid, cam, shot, obj):
134
+ if not all([chunk, vid, cam, shot, obj]) or "-" in [chunk, vid, cam, shot, obj]: return None, None
135
+ orig = os.path.join(CI_VID_DIR, chunk, vid, cam, f"{shot}.mp4")
136
+ edit = os.path.join(STAGE4_DIR, chunk, vid, cam, str(shot), f"{obj}.mp4")
137
+ mask_dir = os.path.join(STAGE3_DIR, chunk, vid, cam, str(shot), str(obj))
138
+ orig_to_show = create_overlay_video(orig, mask_dir, os.path.join(CACHE_DIR, f"ov_{chunk}_{vid}_{cam}_{shot}_{obj}.mp4")) if os.path.exists(orig) and os.path.exists(mask_dir) else (orig if os.path.exists(orig) else None)
139
+ return orig_to_show, (edit if os.path.exists(edit) else None)
140
+
141
+ def merge_videos(chunk, vid, cam, obj, replace_shots):
142
+ if not all([chunk, vid, cam, obj]) or "-" in [chunk, vid, cam, obj]: return None
143
+ all_orig = sorted([p for p in glob.glob(os.path.join(CI_VID_DIR, chunk, vid, cam, "*.mp4")) if os.path.basename(p).replace('.mp4','').isdigit()], key=lambda x: int(os.path.basename(x).split('.')[0]))
144
+ out_path = os.path.join(CACHE_DIR, f"merged_{chunk}_{vid}_{cam}_{obj}.mp4")
145
+ inputs = []
146
+ for p in all_orig:
147
+ sid = os.path.basename(p).replace('.mp4','')
148
+ edit_p = os.path.join(STAGE4_DIR, chunk, vid, cam, sid, f"{obj}.mp4")
149
+ inputs.append(edit_p if (sid in replace_shots and os.path.exists(edit_p)) else p)
150
+ if not inputs: return None
151
+ flt = "".join([f"[{i}:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=24[v{i}];" for i in range(len(inputs))])
152
+ concat = "".join([f"[v{i}]" for i in range(len(inputs))]) + f"concat=n={len(inputs)}:v=1:a=0[outv]"
153
+ cmd = [FFMPEG_PATH, "-y", *sum([["-i", inp] for inp in inputs], []), "-filter_complex", flt + concat, "-map", "[outv]", "-c:v", "libx264", "-preset", "ultrafast", out_path]
154
+ subprocess.run(cmd, check=True, capture_output=True)
155
+ return out_path
156
+
157
+ with gr.Blocks() as app:
158
+ gr.Markdown("# 🎬 视频不一致性检查面板 (Multi-Object版)")
159
+ with gr.Row():
160
+ chunk_dd = gr.Dropdown(choices=CHUNKS, label="1. Chunk", value=C)
161
+ vid_dd = gr.Dropdown(choices=VIDS, label="2. Video ID", value=V)
162
+ cam_dd = gr.Dropdown(choices=CAMS, label="3. Camera ID", value=CAM)
163
+ gr.Markdown("---")
164
+ with gr.Row():
165
+ with gr.Column():
166
+ with gr.Row():
167
+ shot_dd = gr.Dropdown(choices=SHOTS, label="4. Shot", value=S)
168
+ obj_dd = gr.Dropdown(choices=OBJS, label="5. Object", value=O)
169
+ v_orig = gr.Video(label="原始片段 (已叠加红色Mask)")
170
+ v_edit = gr.Video(label="擦除后结果")
171
+ with gr.Column():
172
+ replace = gr.CheckboxGroup(choices=get_valid_replace_shots(C, V, CAM, O), label=f"使用 [{O}] 擦除版的片段", value=get_valid_replace_shots(C, V, CAM, O))
173
+ btn = gr.Button("🚀 一键合成预览视频", variant="primary")
174
+ v_res = gr.Video(label="全序列拼接结果")
175
+
176
+ chunk_dd.change(chunk_update, [chunk_dd], [vid_dd, cam_dd, shot_dd, obj_dd, replace])
177
+ vid_dd.change(vid_update, [chunk_dd, vid_dd], [cam_dd, shot_dd, obj_dd, replace])
178
+ cam_dd.change(cam_update, [chunk_dd, vid_dd, cam_dd], [shot_dd, obj_dd, replace])
179
+ shot_dd.change(shot_update, [chunk_dd, vid_dd, cam_dd, shot_dd], [obj_dd, replace])
180
+ obj_dd.change(obj_update, [chunk_dd, vid_dd, cam_dd, obj_dd], [replace])
181
+
182
+ shot_dd.change(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
183
+ obj_dd.change(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
184
+ btn.click(merge_videos, [chunk_dd, vid_dd, cam_dd, obj_dd, replace], [v_res])
185
+ app.load(load_preview, [chunk_dd, vid_dd, cam_dd, shot_dd, obj_dd], [v_orig, v_edit])
186
+
187
+ if __name__ == "__main__":
188
+ print(f"Link: http://127.0.0.1:7860/")
189
+ app.launch(server_name="0.0.0.0", server_port=7860, share=True, allowed_paths=["/workspace"])