Spaces:
Runtime error
Runtime error
lalashechka
commited on
Commit
•
81a1f6d
1
Parent(s):
df9edd4
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,9 @@ from gradio_client import Client
|
|
18 |
|
19 |
|
20 |
def animate_img(encoded_string, model):
|
|
|
|
|
|
|
21 |
if model == "Stable Video Diffusion":
|
22 |
try:
|
23 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(encoded_string, 'rb')})
|
@@ -45,16 +48,16 @@ def animate_img(encoded_string, model):
|
|
45 |
print("f_1")
|
46 |
except:
|
47 |
print("2")
|
48 |
-
client1 = Client(
|
49 |
result1 = client1.predict(encoded_string, api_name="/resize_image")
|
50 |
-
client = Client(
|
51 |
result = client.predict(result1, 0, True, 1, 15, api_name="/video")
|
52 |
res = result[0]['video']
|
53 |
print("s_2")
|
54 |
return res
|
55 |
|
56 |
if model == "AnimateDiff":
|
57 |
-
client = Client(
|
58 |
result = client.predict(encoded_string, "zoom-out", api_name="/predict")
|
59 |
return result
|
60 |
|
@@ -303,7 +306,7 @@ with gr.Blocks(css=css) as demo:
|
|
303 |
with gr.Tab("Анимировать изображение"):
|
304 |
with gr.Column():
|
305 |
prompt2 = gr.Image(show_label=True, interactive=True, type='filepath', label='Исходное изображение:')
|
306 |
-
prompt12 = gr.Textbox(placeholder="Введите описание видео...", show_label=True, label='Описание видео (опционально):', lines=3)
|
307 |
# motion2 = gr.Dropdown(value="Приближение →←", interactive=True, show_label=True, label="Движение камеры:", choices=["Приближение →←", "Отдаление ←→", "Вверх ↑", "Вниз ↓", "Влево ←", "Вправо →", "По часовой стрелке ⟳", "Против часовой стрелки ⟲"])
|
308 |
model2 = gr.Radio(interactive=True, value="Stable Video Diffusion", show_label=True,
|
309 |
label="Модель нейросети:", choices=['Stable Video Diffusion', 'AnimateDiff'])
|
|
|
18 |
|
19 |
|
20 |
def animate_img(encoded_string, model):
|
21 |
+
url_hg1 = os.getenv("url_hg1")
|
22 |
+
url_hg2 = os.getenv("url_hg2")
|
23 |
+
|
24 |
if model == "Stable Video Diffusion":
|
25 |
try:
|
26 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(encoded_string, 'rb')})
|
|
|
48 |
print("f_1")
|
49 |
except:
|
50 |
print("2")
|
51 |
+
client1 = Client(url_hg1)
|
52 |
result1 = client1.predict(encoded_string, api_name="/resize_image")
|
53 |
+
client = Client(url_hg1)
|
54 |
result = client.predict(result1, 0, True, 1, 15, api_name="/video")
|
55 |
res = result[0]['video']
|
56 |
print("s_2")
|
57 |
return res
|
58 |
|
59 |
if model == "AnimateDiff":
|
60 |
+
client = Client(url_hg2)
|
61 |
result = client.predict(encoded_string, "zoom-out", api_name="/predict")
|
62 |
return result
|
63 |
|
|
|
306 |
with gr.Tab("Анимировать изображение"):
|
307 |
with gr.Column():
|
308 |
prompt2 = gr.Image(show_label=True, interactive=True, type='filepath', label='Исходное изображение:')
|
309 |
+
# prompt12 = gr.Textbox(placeholder="Введите описание видео...", show_label=True, label='Описание видео (опционально):', lines=3)
|
310 |
# motion2 = gr.Dropdown(value="Приближение →←", interactive=True, show_label=True, label="Движение камеры:", choices=["Приближение →←", "Отдаление ←→", "Вверх ↑", "Вниз ↓", "Влево ←", "Вправо →", "По часовой стрелке ⟳", "Против часовой стрелки ⟲"])
|
311 |
model2 = gr.Radio(interactive=True, value="Stable Video Diffusion", show_label=True,
|
312 |
label="Модель нейросети:", choices=['Stable Video Diffusion', 'AnimateDiff'])
|