Revert to working state (8424f66)
Browse files- app.py +0 -1
- src/services/image.py +2 -3
- src/services/video.py +2 -4
- src/ui/handlers.py +2 -30
- src/ui/tabs.py +6 -6
app.py
CHANGED
|
@@ -161,4 +161,3 @@ demo = create_demo()
|
|
| 161 |
|
| 162 |
if __name__ == "__main__":
|
| 163 |
demo.launch()
|
| 164 |
-
|
|
|
|
| 161 |
|
| 162 |
if __name__ == "__main__":
|
| 163 |
demo.launch()
|
|
|
src/services/image.py
CHANGED
|
@@ -105,9 +105,8 @@ class ImageService:
|
|
| 105 |
tool_name="generate_image_edit_5",
|
| 106 |
parameters={
|
| 107 |
"prompt": edit_prompt,
|
| 108 |
-
"
|
| 109 |
-
"
|
| 110 |
-
"height": 1024
|
| 111 |
},
|
| 112 |
on_progress=on_progress
|
| 113 |
)
|
|
|
|
| 105 |
tool_name="generate_image_edit_5",
|
| 106 |
parameters={
|
| 107 |
"prompt": edit_prompt,
|
| 108 |
+
"image_url": image_url,
|
| 109 |
+
"strength": strength
|
|
|
|
| 110 |
},
|
| 111 |
on_progress=on_progress
|
| 112 |
)
|
src/services/video.py
CHANGED
|
@@ -93,10 +93,8 @@ class VideoService:
|
|
| 93 |
tool_name="generate_image_to_video_2",
|
| 94 |
parameters={
|
| 95 |
"prompt": motion_prompt,
|
| 96 |
-
"
|
| 97 |
-
"
|
| 98 |
-
"height": 1280,
|
| 99 |
-
"fps": 24
|
| 100 |
},
|
| 101 |
on_progress=on_progress
|
| 102 |
)
|
|
|
|
| 93 |
tool_name="generate_image_to_video_2",
|
| 94 |
parameters={
|
| 95 |
"prompt": motion_prompt,
|
| 96 |
+
"image_url": image_url,
|
| 97 |
+
"duration": duration
|
|
|
|
|
|
|
| 98 |
},
|
| 99 |
on_progress=on_progress
|
| 100 |
)
|
src/ui/handlers.py
CHANGED
|
@@ -19,18 +19,12 @@ def format_error(error: Exception) -> str:
|
|
| 19 |
msg = str(error)
|
| 20 |
|
| 21 |
# Translate common errors
|
| 22 |
-
if "401" in msg or "unauthorized" in msg.lower():
|
| 23 |
-
return "Invalid API key. Please check your StackNet Key in the Settings section."
|
| 24 |
-
if "403" in msg or "forbidden" in msg.lower():
|
| 25 |
-
return "Access denied. Your API key may not have permission for this operation."
|
| 26 |
if "timeout" in msg.lower():
|
| 27 |
return "The operation timed out. Please try again with a simpler prompt."
|
| 28 |
if "network" in msg.lower() or "connection" in msg.lower():
|
| 29 |
return "Network error. Please check your connection and try again."
|
| 30 |
if "rate limit" in msg.lower() or "429" in msg.lower():
|
| 31 |
return "Too many requests. Please wait a moment and try again."
|
| 32 |
-
if "500" in msg or "internal server error" in msg.lower():
|
| 33 |
-
return "Server error. The service is temporarily unavailable. Please try again later."
|
| 34 |
|
| 35 |
return f"Error: {msg}"
|
| 36 |
|
|
@@ -253,18 +247,7 @@ class Handlers:
|
|
| 253 |
asyncio.set_event_loop(loop)
|
| 254 |
|
| 255 |
try:
|
| 256 |
-
|
| 257 |
-
import base64
|
| 258 |
-
import mimetypes
|
| 259 |
-
|
| 260 |
-
mime_type, _ = mimetypes.guess_type(input_image)
|
| 261 |
-
if not mime_type:
|
| 262 |
-
mime_type = "image/png"
|
| 263 |
-
|
| 264 |
-
with open(input_image, "rb") as f:
|
| 265 |
-
image_data = base64.b64encode(f.read()).decode("utf-8")
|
| 266 |
-
|
| 267 |
-
image_url = f"data:{mime_type};base64,{image_data}"
|
| 268 |
|
| 269 |
images = loop.run_until_complete(
|
| 270 |
service.edit_image(
|
|
@@ -356,18 +339,7 @@ class Handlers:
|
|
| 356 |
asyncio.set_event_loop(loop)
|
| 357 |
|
| 358 |
try:
|
| 359 |
-
|
| 360 |
-
import base64
|
| 361 |
-
import mimetypes
|
| 362 |
-
|
| 363 |
-
mime_type, _ = mimetypes.guess_type(input_image)
|
| 364 |
-
if not mime_type:
|
| 365 |
-
mime_type = "image/png"
|
| 366 |
-
|
| 367 |
-
with open(input_image, "rb") as f:
|
| 368 |
-
image_data = base64.b64encode(f.read()).decode("utf-8")
|
| 369 |
-
|
| 370 |
-
image_url = f"data:{mime_type};base64,{image_data}"
|
| 371 |
|
| 372 |
videos = loop.run_until_complete(
|
| 373 |
service.animate_image(
|
|
|
|
| 19 |
msg = str(error)
|
| 20 |
|
| 21 |
# Translate common errors
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
if "timeout" in msg.lower():
|
| 23 |
return "The operation timed out. Please try again with a simpler prompt."
|
| 24 |
if "network" in msg.lower() or "connection" in msg.lower():
|
| 25 |
return "Network error. Please check your connection and try again."
|
| 26 |
if "rate limit" in msg.lower() or "429" in msg.lower():
|
| 27 |
return "Too many requests. Please wait a moment and try again."
|
|
|
|
|
|
|
| 28 |
|
| 29 |
return f"Error: {msg}"
|
| 30 |
|
|
|
|
| 247 |
asyncio.set_event_loop(loop)
|
| 248 |
|
| 249 |
try:
|
| 250 |
+
image_url = f"file://{input_image}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
images = loop.run_until_complete(
|
| 253 |
service.edit_image(
|
|
|
|
| 339 |
asyncio.set_event_loop(loop)
|
| 340 |
|
| 341 |
try:
|
| 342 |
+
image_url = f"file://{input_image}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
| 344 |
videos = loop.run_until_complete(
|
| 345 |
service.animate_image(
|
src/ui/tabs.py
CHANGED
|
@@ -319,6 +319,12 @@ def create_all_tabs():
|
|
| 319 |
"""Create all tabs and return component references."""
|
| 320 |
tabs = {}
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
with gr.Tab("Text to Image", id="text-to-image"):
|
| 323 |
tabs["text_to_image"] = create_text_to_image_tab()
|
| 324 |
|
|
@@ -331,10 +337,4 @@ def create_all_tabs():
|
|
| 331 |
with gr.Tab("Image to Video", id="image-to-video"):
|
| 332 |
tabs["image_to_video"] = create_image_to_video_tab()
|
| 333 |
|
| 334 |
-
with gr.Tab("Text to Music", id="text-to-music"):
|
| 335 |
-
tabs["text_to_music"] = create_text_to_music_tab()
|
| 336 |
-
|
| 337 |
-
with gr.Tab("Music to Music", id="music-to-music"):
|
| 338 |
-
tabs["music_to_music"] = create_music_to_music_tab()
|
| 339 |
-
|
| 340 |
return tabs
|
|
|
|
| 319 |
"""Create all tabs and return component references."""
|
| 320 |
tabs = {}
|
| 321 |
|
| 322 |
+
with gr.Tab("Text to Music", id="text-to-music"):
|
| 323 |
+
tabs["text_to_music"] = create_text_to_music_tab()
|
| 324 |
+
|
| 325 |
+
with gr.Tab("Music to Music", id="music-to-music"):
|
| 326 |
+
tabs["music_to_music"] = create_music_to_music_tab()
|
| 327 |
+
|
| 328 |
with gr.Tab("Text to Image", id="text-to-image"):
|
| 329 |
tabs["text_to_image"] = create_text_to_image_tab()
|
| 330 |
|
|
|
|
| 337 |
with gr.Tab("Image to Video", id="image-to-video"):
|
| 338 |
tabs["image_to_video"] = create_image_to_video_tab()
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
return tabs
|