jiayong commited on
Commit
f64b15a
1 Parent(s): 3b6aa17

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +474 -0
app.py ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ import gradio as gr
4
+ import threading
5
+ from myconfigs import *
6
+ from oss_utils import ossService
7
+
8
+ from gen_client import *
9
+ myHumanGen = HumanGenService()
10
+ oss_service = ossService()
11
+
12
+ # enable oss resources, if disabled use example mp4 resources from local directory.
13
+ ENABLE_OSS_RESOURCES = True
14
+
15
+ TEST_ENABLED = os.getenv('TEST_ENABLED', 'False')
16
+
17
+ result_video_oss_url = {} # user_id, (list[signed_url), list[oss_path])]
18
+
19
+ def tab_func_template():
20
+ prompt = ""
21
+ return prompt, 'template_mode'
22
+ def tab_func_prompt():
23
+ ref_video_path = None
24
+ return ref_video_path, 'prompt_mode'
25
+
26
+ with open('script.txt', encoding="utf-8") as f:
27
+ script_text_to_load_results = f.read()
28
+
29
+ # def dataset_func(evt: gr.SelectData):
30
+ # ref_video_path = evt.value[0]
31
+ # print("[dataset_func] ref_video_path: ", ref_video_path)
32
+ # # input_prompt = 'haha'
33
+ # if not os.path.exists(ref_video_path):
34
+ # raise gr.Error(f"The input video {ref_video_path} is not existed!")
35
+ # video_file_name = os.path.basename(ref_video_path)
36
+ # __, input_prompt = myHumanGen.template_video_2_prompt(video_file_name)
37
+ # return ref_video_path,input_prompt
38
+
39
+ def video_2_prompt_func(ref_video_path):
40
+ print("[dataset_func] ref_video_path: %s" % ref_video_path)
41
+ if not os.path.exists(ref_video_path):
42
+ raise gr.Error(f"The input video {ref_video_path} is not existed!")
43
+ video_file_name = os.path.basename(ref_video_path)
44
+ print("[dataset_func] video_file_name: %s" % video_file_name)
45
+ __, input_prompt = myHumanGen.template_video_2_prompt(video_file_name)
46
+ print("[dataset_func] input_prompt: %s" % input_prompt)
47
+ return ref_video_path,input_prompt
48
+
49
+
50
+ def get_user_result_video_list(uuid, date_string, num):
51
+ directory='video_generation/Service/'+date_string+'/'+uuid+'/'
52
+ for obj in oss2.ObjectIterator(oss_service.bucket, prefix=directory, delimiter='/'):
53
+ print(f"目录存在:{directory}")
54
+ break
55
+ else:
56
+ print(f"目录不存在:{directory}")
57
+ return [],[]
58
+ no_check_video_list = []
59
+ no_check_timer_list = []
60
+ for obj in oss2.ObjectIterator(oss_service.bucket, prefix=directory, delimiter = '/'):
61
+ if obj.is_prefix(): # 判断obj为文件夹。
62
+ file_full_path = obj.key+'result.mp4'
63
+ exist = oss_service.bucket.object_exists(file_full_path)
64
+
65
+ if not exist:
66
+ print(f'file_full_path is not existed')
67
+ tmp_directory=obj.key
68
+ print(f'tmp_directory = {tmp_directory}')
69
+ for obj_xxx in oss2.ObjectIterator(oss_service.bucket, prefix=tmp_directory, delimiter = '/'):
70
+ print(f'obj_xxx.key = {obj_xxx.key}')
71
+ if obj_xxx.is_prefix(): # 判断obj为文件夹
72
+ pass
73
+ else:
74
+ import re
75
+ pattern = r"dreamoving-.*-result\.mp4"
76
+ # Extract the MP4 file name
77
+ file_name_xxx = os.path.basename(obj_xxx.key)
78
+ match = re.search(pattern, obj_xxx.key)
79
+ if match and len(match.group()) == len(file_name_xxx):
80
+ file_full_path = obj_xxx.key
81
+ print(f'successfully match file_full_path: {file_full_path}')
82
+ exist = True
83
+ break
84
+ else:
85
+ pass
86
+
87
+ if exist:
88
+ object_meta = oss_service.bucket.head_object(file_full_path)
89
+ bytes_num = object_meta.headers.get('Content-Length') # bytes
90
+ # print(f"Object Size: {bytes_num} bytes")
91
+ mb_num = float(bytes_num) / (1000 ** 2) # MB
92
+ # print(f"Object Size: {mb_num} MB")
93
+
94
+ if mb_num > 0.1: # 大于100KB
95
+ last_modified = object_meta.headers.get('Last-Modified')
96
+ # print(f"Last Modified: {last_modified}")
97
+ from email.utils import parsedate_to_datetime
98
+ # 将 HTTP-date 格式字符串转换为 datetime 对象
99
+ last_modified_datetime = parsedate_to_datetime(last_modified)
100
+ # 将 datetime 对象转换为 Unix 时间戳(整数秒)-自1970年1月1日UTC以来的秒数
101
+ last_modified_timestamp = int(last_modified_datetime.timestamp())
102
+ # print(f"Last Modified (timestamp): {last_modified_timestamp}")
103
+
104
+ no_check_video_list.append(file_full_path)
105
+ no_check_timer_list.append(last_modified_timestamp)
106
+ else:
107
+ print(f'文件太小: {file_full_path}')
108
+ else: # 判断obj为文件。
109
+ print(f'这不是文件夹: {obj.key}')
110
+ # last_modified = obj.last_modified # 文件的最后修改时间
111
+ # print(f"File: {obj.key}, Last Modified: {last_modified}")
112
+
113
+ valid_video_list = []
114
+ valid_image_list = []
115
+ if len(no_check_video_list) > 0:
116
+ if len(no_check_video_list) > 1:
117
+ # sort by time
118
+ zipped_lists = zip(no_check_timer_list, no_check_video_list) # 合并为元组
119
+ sorted_pairs = sorted(zipped_lists, key=lambda x: x[0], reverse=True) # 从大到小
120
+ list1_sorted, list2_sorted = zip(*sorted_pairs)
121
+ no_check_timer_list = list(list1_sorted)
122
+ no_check_video_list = list(list2_sorted)
123
+
124
+ for file_full_path in no_check_video_list:
125
+ oss_video_path = "oss://vigen-invi/" + file_full_path
126
+ print(f'生成的视频: {oss_video_path}')
127
+ _, video_url = oss_service.sign(oss_video_path, timeout=3600*100)
128
+ valid_video_list.append(video_url)
129
+ style = "video/snapshot,t_1000,f_jpg,w_544,h_768,m_fast"
130
+ params1 = {'x-oss-process': style}
131
+ _, snapshot_image = oss_service.sign(oss_video_path, timeout=3600*100, params=params1)
132
+ valid_image_list.append(snapshot_image)
133
+ if len(valid_video_list) >= num:
134
+ break
135
+ return valid_video_list, valid_image_list
136
+
137
+ def refresh_video(uuid, request_id):
138
+ notes, process_status = myHumanGen.get_ranking_location(uuid)
139
+ if is_wanx_platform:
140
+ uuid = 'wanx_lab'
141
+ if uuid is None or uuid == '':
142
+ uuid = 'test_version_phone'
143
+ print(f'[refresh_video] uuid: {uuid}')
144
+ print(f'[refresh_video] request_id: {request_id}')
145
+ new_list = []
146
+ new_image_list = []
147
+ if process_status == 'runing':
148
+ print(f'process_status: {process_status}')
149
+ # video_oss_path = "oss://vigen-invi/video_generation/logo/runing.mp4"
150
+ # _, video_url = oss_service.sign(video_oss_path, timeout=3600*100)
151
+ # new_list.append(video_url)
152
+ # img_oss_path = "oss://vigen-invi/video_generation/logo/runing.png"
153
+ # _, img_url = oss_service.sign(img_oss_path, timeout=3600*100)
154
+ # new_image_list.append(img_url)
155
+ new_list.append(None)
156
+ new_image_list.append(None)
157
+ date_string = datetime.datetime.now().strftime('%Y-%m-%d')
158
+ valid_video_list, valid_image_list = get_user_result_video_list(uuid, date_string, 3)
159
+ new_list = new_list + valid_video_list
160
+ new_image_list = new_image_list + valid_image_list
161
+ if len(new_list) < 4:
162
+ date_string_yesterday = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
163
+ valid_video_list1, valid_image_list1 = get_user_result_video_list(uuid, date_string_yesterday, 4-len(new_list))
164
+ new_list = new_list + valid_video_list1
165
+ new_image_list = new_image_list + valid_image_list1
166
+ if len(new_list) < 4:
167
+ date_string_bf_yesterday = (datetime.datetime.now() - datetime.timedelta(days=2)).strftime('%Y-%m-%d')
168
+ valid_video_list2, valid_image_list2 = get_user_result_video_list(uuid, date_string_bf_yesterday, 4-len(new_list))
169
+ new_list = new_list + valid_video_list2
170
+ new_image_list = new_image_list + valid_image_list2
171
+ if len(new_list) < 4:
172
+ for i in range(4-len(new_list)):
173
+ new_list.append(None)
174
+ new_image_list.append(None)
175
+ else:
176
+ date_string = datetime.datetime.now().strftime('%Y-%m-%d')
177
+ valid_video_list, valid_image_list = get_user_result_video_list(uuid, date_string, 4)
178
+ new_list = valid_video_list
179
+ new_image_list = valid_image_list
180
+ if len(new_list) < 4:
181
+ date_string_yesterday = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
182
+ valid_video_list1, valid_image_list1 = get_user_result_video_list(uuid, date_string_yesterday, 4-len(new_list))
183
+ new_list = new_list + valid_video_list1
184
+ new_image_list = new_image_list + valid_image_list1
185
+ if len(new_list) < 4:
186
+ date_string_bf_yesterday = (datetime.datetime.now() - datetime.timedelta(days=2)).strftime('%Y-%m-%d')
187
+ valid_video_list2, valid_image_list2 = get_user_result_video_list(uuid, date_string_bf_yesterday, 4-len(new_list))
188
+ new_list = new_list + valid_video_list2
189
+ new_image_list = new_image_list + valid_image_list2
190
+ if len(new_list) < 4:
191
+ for i in range(4-len(new_list)):
192
+ new_list.append(None)
193
+ new_image_list.append(None)
194
+
195
+ return notes, new_list[0], new_list[1], new_list[2], new_list[3], new_image_list[0], new_image_list[1], new_image_list[2], new_image_list[3]
196
+
197
+ with gr.Blocks(title = "追影",
198
+ css='style.css',
199
+ theme=gr.themes.Soft(
200
+ radius_size=gr.themes.sizes.radius_sm,
201
+ text_size=gr.themes.sizes.text_md
202
+ )
203
+ ) as demo:
204
+ with gr.Row():
205
+ gr.HTML(f"""
206
+ <div id='logo'>
207
+ <div
208
+ style="
209
+ margin-left: 0px !important;
210
+ "
211
+ >
212
+ <img id='logo_img' src='{RESOURCES.logo_img0}' >
213
+ </div>
214
+ </br>
215
+ """)
216
+
217
+ template_videos_to_ref = examples['template_video']
218
+ if ENABLE_OSS_RESOURCES:
219
+ template_videos_to_ref = []
220
+ template_video_list = examples['template_video']
221
+ for i in range(9):
222
+ file_name = template_video_list[i]
223
+ oss_path = "oss://vigen-invi/video_generation/template_video1/" + file_name
224
+ _, url = oss_service.sign(oss_path, timeout=3600*100)
225
+ template_videos_to_ref.append(url)
226
+
227
+ with gr.Accordion(label="🧭 使用指南:建议先阅读此说明再使用!", open=False):
228
+ gr.Markdown("""
229
+ - ⭐️ 1、视频生成时间在7分钟左右,由于并发人数多,生成任务可能要排队,请点击刷新按钮后查看提示信息;
230
+ - ⭐️ 2、如果输入图像为卡通图片,一定要勾选“卡通化视频生成”。
231
+ - ⭐️ 3、系统保留最多4个最近两天生成的视频,0点刷新,请及时下载保存。
232
+ - ⭐️ 4、系统更新一般在早上7~8点。
233
+ """)
234
+
235
+ input_mode = gr.Text(value="prompt_mode", label="input_mode", visible=False)
236
+ with gr.Row():
237
+ with gr.Column(scale=1): # 左侧一列
238
+ # gr.Markdown("输入形象和动作",elem_id='font_style')
239
+ with gr.Box(elem_id='show_box'):
240
+ gr.Markdown("输入你的形象")
241
+ with gr.Column():
242
+ with gr.Box(elem_id='show_box1'):
243
+ with gr.Row(): # 图片输入
244
+ #左侧图片预览
245
+ ref_image = gr.Image(source='upload', type='filepath', show_label=False, label='输入图片',elem_id='show_window_image')
246
+ #右侧图片列表
247
+ gr.Examples(examples['examples_images'], examples_per_page=9, inputs=[ref_image], label='')
248
+
249
+ with gr.Row(): # checkbox
250
+ # 模型切换
251
+ model_id = gr.Checkbox(label="卡通视频生成", show_label=False)
252
+
253
+ with gr.Column(): # 文字/视频输入
254
+ gr.Markdown("选择视频动作的参考视频或者文本描述")
255
+
256
+ with gr.Tab("文生视频") as tab1:
257
+ # prompt = gr.Textbox(label="Prompt提示词", show_label=False, text_align='left')
258
+ example_prompts= []
259
+ file = open(ref_video_prompt, 'r')
260
+ for line in file.readlines():
261
+ example_prompts.append(line)
262
+ file.close()
263
+ prompt = gr.Dropdown(label="Prompt提示词",choices=example_prompts, show_label=False, allow_custom_value=True)
264
+
265
+ with gr.Tab("同款生成") as tab0: # 视频模板
266
+ prompt_template = gr.Textbox(placeholder="输入提示词控制生成效果,如人物,人物的服饰、场景等,支持中/英文输入。",label="Prompt提示词", lines=2,interactive=True,show_label=False, text_align='left')
267
+ with gr.Row():
268
+ # FIXME: the width/height setting not work here, TODO: CSS 调整
269
+ ref_video = gr.Video(source='upload', type='filepath', show_label=False, label='输入视频', autoplay=True, elem_id='show_window_video', width=224, height=360)
270
+ # gr.Examples(examples['template_video'], examples_per_page=9,inputs=[ref_video], label='样例视频')
271
+ # dataset_select = gr.Dataset(
272
+ # label='样例视频',
273
+ # components=[gr.Video(visible=False)],
274
+ # samples=examples['template_video'],
275
+ # samples_per_page=9,
276
+ # type='index', # pass index or value
277
+ # # min_width=400,
278
+ # # elem_id='dataset',
279
+ # # elem_id='template_param',
280
+ # )
281
+ gr.Examples(
282
+ label='样例视频',
283
+ examples=template_videos_to_ref,
284
+ inputs=ref_video,
285
+ outputs=[ref_video, prompt_template],
286
+ fn=video_2_prompt_func,
287
+ examples_per_page=9,
288
+ cache_examples=True, #run_on_click=True,
289
+ )
290
+ # prompt_template = gr.Textbox(label="Prompt提示词", lines=2,interactive=True,show_label=False, text_align='left')
291
+
292
+ with gr.Row(): # 生成button
293
+ # 生成按钮
294
+ run_button = gr.Button(value="生成视频", elem_id='button_param')
295
+ # btn = gr.Button("生成视频").style(full_width=False)
296
+
297
+ with gr.Column(scale=1): # 右侧一列
298
+ # gr.Markdown("生成视频",elem_id='font_style')
299
+ with gr.Box(elem_id='show_box2'):
300
+ with gr.Row():
301
+ with gr.Box(elem_id='box_show4'):
302
+ with gr.Column(scale=0.33, min_width=0.33):
303
+ gr.Markdown("生成视频",elem_id='font_style')
304
+ with gr.Column(scale=0.33, min_width=0.33):
305
+ user_notes = gr.Textbox(show_label=False, text_align='left', elem_id='text_style11')
306
+ with gr.Column(scale=0.33, min_width=0.33):
307
+ refresh_button = gr.Button(value="刷新", elem_id='button_param1')
308
+
309
+ with gr.Row():
310
+ output_video0 = gr.Video(type="mp4", show_label=False, label="Result Video", autoplay=True, elem_id='show_window_result1', elem_classes="show_window_result")
311
+ output_snapshot_image0 = gr.Image(source='upload', type='filepath', show_label=False, interactive=False, elem_id='output_snapshot_image1', width=200,height=1, visible=False)
312
+ output_video1 = gr.Video(type="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result2', elem_classes="show_window_result")
313
+ output_snapshot_image1 = gr.Image(source='upload', type='filepath', show_label=False, interactive=False, elem_id='output_snapshot_image2', width=200,height=1, visible=False)
314
+ with gr.Row():
315
+ output_video2 = gr.Video(type="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result3', elem_classes="show_window_result")
316
+ output_snapshot_image2 = gr.Image(source='upload', type='filepath', show_label=False, interactive=False, elem_id='output_snapshot_image3', width=200,height=1, visible=False)
317
+ output_video3 = gr.Video(type="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result4', elem_classes="show_window_result")
318
+ output_snapshot_image3 = gr.Image(source='upload', type='filepath', show_label=False, interactive=False, elem_id='output_snapshot_image4', width=200,height=1, visible=False)
319
+
320
+ uuid = gr.Text(label="modelscope_uuid", visible=False)
321
+ request_id = gr.Text(label="modelscope_request_id", visible=False)
322
+
323
+ # 展示生成的视频
324
+ img_lists = []
325
+ mp4_lists = get_dirnames(filePath="./data/sample_video", tail=".mp4")
326
+ # mp4_listss = [[i] for i in mp4_lists]
327
+ # gr.Markdown("样例视频",elem_id='font_style')
328
+ # ref_video1 = gr.Video(source='upload', height=400, type='filepath', show_label=False, visible=False, label='输入视频',elem_id='show_window_video')
329
+ # with gr.Box():
330
+ # gr.Examples(mp4_listss, examples_per_page=12, inputs=[ref_video1], label='')
331
+
332
+ if ENABLE_OSS_RESOURCES:
333
+ mp4_url_list = []
334
+ for i in range(min(12, len(mp4_lists))):
335
+ file_name = os.path.basename(mp4_lists[i])
336
+ # file_name = str(i) + ".mp4"
337
+ oss_path = "oss://vigen-invi/video_generation/sample_video/" + file_name
338
+ _, video_url = oss_service.sign(oss_path, timeout=3600*100)
339
+ mp4_url_list.append(video_url)
340
+ mp4_lists = mp4_url_list
341
+
342
+ num_videos_per_row = 4
343
+ num_video = 8
344
+ if len(mp4_lists) <= num_video:
345
+ num_video = len(mp4_lists)
346
+ with gr.Row():
347
+ gr.Markdown("样例视频",elem_id='font_style')
348
+ with gr.Box(elem_id='show_box'):
349
+ with gr.Column():
350
+ for i in range(int((num_video+num_videos_per_row-1)/num_videos_per_row)):
351
+ with gr.Row():
352
+ for j in range(num_videos_per_row):
353
+ if i*num_videos_per_row+j < len(mp4_lists):
354
+ gr.Video(value=mp4_lists[i*num_videos_per_row+j], show_label=False, interactive=False, label='result')
355
+ else:
356
+ gr.Video(interactive=False, label='result')
357
+
358
+ refresh_button.click(
359
+ fn=refresh_video,
360
+ queue = False,
361
+ inputs=[uuid, request_id],
362
+ outputs=[user_notes, output_video0, output_video1, output_video2, output_video3,
363
+ output_snapshot_image0, output_snapshot_image1, output_snapshot_image2, output_snapshot_image3 ]
364
+ )
365
+
366
+ # dataset_select.select(fn=dataset_func, outputs=[ref_video,prompt_template])
367
+
368
+ # button触发
369
+ tab0.select(fn=tab_func_template, outputs=[prompt, input_mode]) # 视频模板模式
370
+ tab1.select(fn=tab_func_prompt, outputs=[ref_video, input_mode]) # prompt模式
371
+
372
+ def async_process(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt='', prompt_template='',model_id=False):
373
+ # 入参检查
374
+ check_note_info = myHumanGen.valid_check(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt, prompt_template,model_id)
375
+
376
+ if check_note_info == '':
377
+ # 创建独立线程处理
378
+ thread = threading.Thread(target=myHumanGen.click_button_func_async, args=(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt, prompt_template,model_id,))
379
+ thread.start()
380
+ # thread.join()
381
+ time.sleep(5)
382
+
383
+ return refresh_video(user_id, request_id)
384
+ else:
385
+ notes, video_0, video_1, video_2, video_3, image_0, image_1, image_2, image_3 = refresh_video(user_id, request_id)
386
+ return check_note_info, video_0, video_1, video_2, video_3, image_0, image_1, image_2, image_3
387
+
388
+ if TEST_ENABLED == "True":
389
+ run_button.click(fn=myHumanGen.click_button_mock_test, inputs=[uuid, request_id, input_mode, ref_image, ref_video, prompt, prompt_template, model_id], outputs=[])
390
+ else:
391
+ # run_button.click(fn=myHumanGen.click_button_func_async, inputs=[uuid, request_id, input_mode, ref_image, ref_video, prompt, prompt_template, model_id], outputs=[])
392
+ run_button.click(fn=async_process, inputs=[uuid, request_id, input_mode, ref_image, ref_video, prompt, prompt_template, model_id], outputs=[user_notes, output_video0, output_video1, output_video2, output_video3,
393
+ output_snapshot_image0, output_snapshot_image1, output_snapshot_image2, output_snapshot_image3])
394
+
395
+
396
+ # with gr.Accordion(label="RELEASE_NOTE", elem_id="release_note"):
397
+ # gr.HighlightedText(label="🔊 MESSAGE", value=[("状态","开发中"),("进度", "55%")], elem_classes='info')
398
+ with gr.Row():
399
+ # gr.Textbox(label="RELEASE_NOTE",
400
+ # show_label=False,
401
+ # value=RELEASE_NOTE,
402
+ # lines=3,
403
+ # max_lines=3,
404
+ # interactive=False, scale=2)
405
+ # 钉钉群二维码信息
406
+ gr.HTML(f"""
407
+ <div id=css_img_QRCode>
408
+ <img id=css_img_QRCode src='{RESOURCES.logo_dingding}'>
409
+ </div>
410
+ <div id=css_img_QRCode_text>
411
+ 追影需求共建钉钉群
412
+ </div>
413
+
414
+ """)
415
+ # 微信群二维码信息
416
+ gr.HTML(f"""
417
+ <div id=css_img_QRCode>
418
+ <img id=css_img_QRCode src='{RESOURCES.logo_wechat}'>
419
+ </div>
420
+ <div id=css_img_QRCode_text>
421
+ 追影需求共建微信群
422
+ </div>
423
+ """)
424
+
425
+
426
+ # 显示版本号
427
+ gr.HTML(f"""
428
+ </br>
429
+ <div>
430
+ <center> Version: {VERSION} </center>
431
+ </div>
432
+ """)
433
+
434
+ if ENABLE_OSS_RESOURCES:
435
+ snapshots = ""
436
+ sample_video_list = get_dirnames(filePath="./data/sample_video", tail=".mp4")
437
+ for i in range(12):
438
+ if i < len(sample_video_list):
439
+ file_name = os.path.basename(sample_video_list[i])
440
+ oss_path = "oss://vigen-invi/video_generation/sample_video/" + file_name
441
+ style = "video/snapshot,t_1000,f_jpg,w_560,h_800,m_fast"
442
+ params = {'x-oss-process': style}
443
+ _, url = oss_service.sign(oss_path, timeout=3600*100, params=params)
444
+ snapshots = snapshots + url + ";"
445
+
446
+ referenceVideoSnapshots = ""
447
+ template_video_list = examples['template_video']
448
+ for i in range(9):
449
+ if i < len(template_video_list):
450
+ file_name = template_video_list[i]
451
+ oss_path = "oss://vigen-invi/video_generation/template_video1/" + file_name
452
+ style = "video/snapshot,t_1000,f_jpg,w_56,h_80,m_fast" #112,160
453
+ params = {'x-oss-process': style}
454
+ _, url = oss_service.sign(oss_path, timeout=3600*100, params=params)
455
+ referenceVideoSnapshots = referenceVideoSnapshots + url + ";"
456
+ format_text = script_text_to_load_results.format(snapshots, referenceVideoSnapshots)
457
+ demo.load(_js = format_text)
458
+
459
+
460
+ demo.queue(api_open=False, concurrency_count=1000).launch(
461
+ server_name="0.0.0.0" if os.getenv('GRADIO_LISTEN', '') != '' else "127.0.0.1",
462
+ share=False,
463
+ server_port=7861,
464
+ root_path=f"/{os.getenv('GRADIO_PROXY_PATH')}" if os.getenv('GRADIO_PROXY_PATH') else ""
465
+ )
466
+
467
+ # demo.launch(
468
+ # server_name="0.0.0.0" if os.getenv('GRADIO_LISTEN', '') != '' else "127.0.0.1",
469
+ # share=False,
470
+ # enable_queue=True,
471
+ # root_path=f"/{os.getenv('GRADIO_PROXY_PATH')}" if os.getenv('GRADIO_PROXY_PATH') else ""
472
+ # )
473
+
474
+