Spaces:
Running
Running
wenyi
commited on
Commit
•
b0153c0
1
Parent(s):
0b4dc52
app by zyf
Browse files
app.py
CHANGED
@@ -19,14 +19,41 @@ Since the translation model may mistranslate, you may want to use the translatio
|
|
19 |
NOTES = 'This app is adapted from <a href="https://github.com/hysts/CogVideo_demo">https://github.com/hysts/CogVideo_demo</a>. It would be recommended to use the repo if you want to run the app yourself.'
|
20 |
FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=THUDM.CogVideo" />'
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
def main():
|
24 |
only_first_stage = True
|
25 |
# model = AppModel(only_first_stage)
|
26 |
|
27 |
with gr.Blocks(css='style.css') as demo:
|
28 |
-
gr.Markdown(MAINTENANCE_NOTICE)
|
29 |
-
|
30 |
gr.Markdown(DESCRIPTION)
|
31 |
|
32 |
with gr.Row():
|
@@ -56,18 +83,18 @@ def main():
|
|
56 |
with gr.TabItem('Output (Video)'):
|
57 |
result_video = gr.Video(show_label=False)
|
58 |
|
59 |
-
examples = gr.Examples(
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
gr.Markdown(NOTES)
|
68 |
gr.Markdown(FOOTER)
|
69 |
print(gr.__version__)
|
70 |
-
run_button.click(fn=
|
71 |
inputs=[
|
72 |
text,
|
73 |
translate,
|
@@ -77,7 +104,7 @@ def main():
|
|
77 |
],
|
78 |
outputs=[translated_text, result_video])
|
79 |
print(gr.__version__)
|
80 |
-
|
81 |
demo.launch()
|
82 |
|
83 |
|
|
|
19 |
NOTES = 'This app is adapted from <a href="https://github.com/hysts/CogVideo_demo">https://github.com/hysts/CogVideo_demo</a>. It would be recommended to use the repo if you want to run the app yourself.'
|
20 |
FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=THUDM.CogVideo" />'
|
21 |
|
22 |
+
import json
|
23 |
+
import requests
|
24 |
+
|
25 |
+
def post(
|
26 |
+
text,
|
27 |
+
translate,
|
28 |
+
seed,
|
29 |
+
only_first_stage,
|
30 |
+
image_prompt
|
31 |
+
):
|
32 |
+
url = 'https://ccb8is4fqtofrtdsfjebg.ml-platform-cn-beijing.volces.com/devinstance/di-20221130120908-bhpxq/proxy/6201/cogvideo-s1'
|
33 |
+
headers = {
|
34 |
+
"Content-Type": "application/json; charset=UTF-8",
|
35 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36",
|
36 |
+
}
|
37 |
+
|
38 |
+
data = json.dumps({'text': text,
|
39 |
+
'translate': translate,
|
40 |
+
'seed': seed,
|
41 |
+
'only_first_stage': only_first_stage,
|
42 |
+
'image_prompt': image_prompt
|
43 |
+
})
|
44 |
+
r = requests.post(url, data, headers=headers)
|
45 |
+
|
46 |
+
translated_text = r.json()['data']['translated_text']
|
47 |
+
result_video = r.json()['data']['result_video']
|
48 |
+
return translated_text, result_video
|
49 |
|
50 |
def main():
|
51 |
only_first_stage = True
|
52 |
# model = AppModel(only_first_stage)
|
53 |
|
54 |
with gr.Blocks(css='style.css') as demo:
|
55 |
+
# gr.Markdown(MAINTENANCE_NOTICE)
|
56 |
+
|
57 |
gr.Markdown(DESCRIPTION)
|
58 |
|
59 |
with gr.Row():
|
|
|
83 |
with gr.TabItem('Output (Video)'):
|
84 |
result_video = gr.Video(show_label=False)
|
85 |
|
86 |
+
# examples = gr.Examples(
|
87 |
+
# examples=[['骑滑板的皮卡丘', False, 1234, True,None],
|
88 |
+
# ['a cat playing chess', True, 1253, True,None]],
|
89 |
+
# fn=model.run_with_translation,
|
90 |
+
# inputs=[text, translate, seed, only_first_stage,image_prompt],
|
91 |
+
# outputs=[translated_text, result_video],
|
92 |
+
# cache_examples=True)
|
93 |
|
94 |
gr.Markdown(NOTES)
|
95 |
gr.Markdown(FOOTER)
|
96 |
print(gr.__version__)
|
97 |
+
run_button.click(fn=post,
|
98 |
inputs=[
|
99 |
text,
|
100 |
translate,
|
|
|
104 |
],
|
105 |
outputs=[translated_text, result_video])
|
106 |
print(gr.__version__)
|
107 |
+
|
108 |
demo.launch()
|
109 |
|
110 |
|