Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
-
from gradio_client import Client
|
| 4 |
import time
|
| 5 |
import requests
|
| 6 |
from deep_translator import GoogleTranslator
|
| 7 |
from langdetect import detect
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
MORE = """ ## TRY Other Models
|
| 11 |
-
### JARVIS: Your VOICE Assistant -> https://huggingface.co/spaces/KingNish/JARVIS
|
| 12 |
-
### Instant Image: 4k images in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Image
|
| 13 |
-
"""
|
| 14 |
|
| 15 |
# Gradio Client
|
| 16 |
client = Client("KingNish/Instant-Video")
|
|
@@ -33,10 +28,17 @@ def generate_image(prompt, base="Anime", motion="", step=8, progress=gr.Progress
|
|
| 33 |
)
|
| 34 |
video_path = result["video"]
|
| 35 |
return video_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
except ValueError as e:
|
| 37 |
print(f"Ошибка подключения.")
|
| 38 |
raise gr.Error("Не удалось подключиться к API. Повторите попытку позже или обратитесь к администраторам Neurix.")
|
| 39 |
-
|
| 40 |
|
| 41 |
# Ссылка на файл CSS
|
| 42 |
css_url = "https://neurixyufi-aihub.static.hf.space/style.css"
|
|
@@ -124,4 +126,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 124 |
outputs=video,
|
| 125 |
)
|
| 126 |
|
| 127 |
-
demo.queue(max_size=250).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
from gradio_client import Client, APIError
|
| 4 |
import time
|
| 5 |
import requests
|
| 6 |
from deep_translator import GoogleTranslator
|
| 7 |
from langdetect import detect
|
| 8 |
+
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Gradio Client
|
| 11 |
client = Client("KingNish/Instant-Video")
|
|
|
|
| 28 |
)
|
| 29 |
video_path = result["video"]
|
| 30 |
return video_path
|
| 31 |
+
except APIError as e:
|
| 32 |
+
error_message = str(e)
|
| 33 |
+
match = re.search(r'You have exceeded your GPU quota \((\d+:\d+:\d+) left vs. \d+s requested\). Please retry in (\d+:\d+:\d+)\.', error_message)
|
| 34 |
+
if match:
|
| 35 |
+
wait_time = match.group(2)
|
| 36 |
+
raise gr.Error(f"У модели сработало ограничение (Слишком часто), попробуйте ещё раз в *время: {wait_time}*")
|
| 37 |
+
else:
|
| 38 |
+
raise gr.Error("Произошла ошибка при подключении к API. Повторите попытку позже или обратитесь к администраторам Neurix.")
|
| 39 |
except ValueError as e:
|
| 40 |
print(f"Ошибка подключения.")
|
| 41 |
raise gr.Error("Не удалось подключиться к API. Повторите попытку позже или обратитесь к администраторам Neurix.")
|
|
|
|
| 42 |
|
| 43 |
# Ссылка на файл CSS
|
| 44 |
css_url = "https://neurixyufi-aihub.static.hf.space/style.css"
|
|
|
|
| 126 |
outputs=video,
|
| 127 |
)
|
| 128 |
|
| 129 |
+
demo.queue(max_size=250).launch()
|