Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,7 @@ import requests
|
|
| 22 |
import numpy as np
|
| 23 |
import imageio.v2 as iio
|
| 24 |
import base64
|
|
|
|
| 25 |
|
| 26 |
def post(
|
| 27 |
text,
|
|
@@ -41,24 +42,30 @@ def post(
|
|
| 41 |
else:
|
| 42 |
encoded_img = None
|
| 43 |
print('开始请求...')
|
| 44 |
-
data = json.dumps({'text': text,
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
r = requests.post(url, data, headers=headers)
|
| 51 |
-
print('请求完毕...')
|
| 52 |
-
translated_text = r.json()['data']['translated_text']
|
| 53 |
-
result_video = r.json()['data']['result_video']
|
| 54 |
-
frames = r.json()['data']['frames']
|
| 55 |
-
|
|
|
|
| 56 |
num_videos = 2
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
print('finished')
|
| 63 |
return result_video[0], result_video[1]
|
| 64 |
# return result_video[0], result_video[1], result_video[2], result_video[3]
|
|
|
|
| 22 |
import numpy as np
|
| 23 |
import imageio.v2 as iio
|
| 24 |
import base64
|
| 25 |
+
import urllib.request
|
| 26 |
|
| 27 |
def post(
|
| 28 |
text,
|
|
|
|
| 42 |
else:
|
| 43 |
encoded_img = None
|
| 44 |
print('开始请求...')
|
| 45 |
+
# data = json.dumps({'text': text,
|
| 46 |
+
# 'translate': translate,
|
| 47 |
+
# 'seed': seed,
|
| 48 |
+
# 'only_first_stage': only_first_stage,
|
| 49 |
+
# 'image_prompt': encoded_img
|
| 50 |
+
# })
|
| 51 |
+
# r = requests.post(url, data, headers=headers)
|
| 52 |
+
# print('请求完毕...')
|
| 53 |
+
# translated_text = r.json()['data']['translated_text']
|
| 54 |
+
# result_video = r.json()['data']['result_video']
|
| 55 |
+
# frames = r.json()['data']['frames']
|
| 56 |
+
|
| 57 |
+
# urllib.request.urlretrieve(url, filename)
|
| 58 |
num_videos = 2
|
| 59 |
+
url = "http://cogview.cn-wlcb.ufileos.com/tmpr4kcld7k0.mp4"
|
| 60 |
+
result_video[0] = "./temp1.mp4"
|
| 61 |
+
result_video[1] = "./temp2.mp4"
|
| 62 |
+
urllib.request.urlretrieve(url, result_video[0])
|
| 63 |
+
urllib.request.urlretrieve(url, result_video[1])
|
| 64 |
+
# for i in range(num_videos):
|
| 65 |
+
# writer = iio.get_writer(result_video[i], fps=4)
|
| 66 |
+
# for frame in frames[i]:
|
| 67 |
+
# writer.append_data(np.array(frame))
|
| 68 |
+
# writer.close()
|
| 69 |
print('finished')
|
| 70 |
return result_video[0], result_video[1]
|
| 71 |
# return result_video[0], result_video[1], result_video[2], result_video[3]
|