Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
import
|
4 |
-
|
5 |
|
6 |
|
7 |
MORE = """ ## TRY Other Models
|
@@ -11,24 +11,23 @@ MORE = """ ## TRY Other Models
|
|
11 |
|
12 |
# Function
|
13 |
def generate_image(prompt, base="Anime", motion="", step=8, progress=gr.Progress()):
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
return video_path
|
32 |
|
33 |
# Gradio Interface
|
34 |
with gr.Blocks(css="style.css") as demo:
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
from gradio_client import Client
|
4 |
+
import time
|
5 |
|
6 |
|
7 |
MORE = """ ## TRY Other Models
|
|
|
11 |
|
12 |
# Function
|
13 |
def generate_image(prompt, base="Anime", motion="", step=8, progress=gr.Progress()):
|
14 |
+
retries = 3
|
15 |
+
for i in range(retries):
|
16 |
+
try:
|
17 |
+
result = client.predict(
|
18 |
+
prompt=prompt,
|
19 |
+
base=base,
|
20 |
+
motion=motion,
|
21 |
+
step=step,
|
22 |
+
api_name="/generate_image_1"
|
23 |
+
)
|
24 |
+
video_path = result["video"]
|
25 |
+
return video_path
|
26 |
+
except ValueError as e:
|
27 |
+
print(f"Ошибка подключения. Попытка {i+1} из {retries}.")
|
28 |
+
raise gr.Info(f"Ошибка подключения. Попытка {i+1} из {retries}.")
|
29 |
+
time.sleep(5) # Пауза перед следующей попыткой
|
30 |
+
raise gr.Error("Не удалось подключиться к API. Повторите попытку позже.")
|
|
|
31 |
|
32 |
# Gradio Interface
|
33 |
with gr.Blocks(css="style.css") as demo:
|