Fix Image to Image and Image to Video uploads
Browse files- Use 'image' parameter instead of 'image_url'
- Convert local files to base64 data URLs for API
- Add proper dimensions to API calls
- src/services/image.py +3 -2
- src/services/video.py +4 -2
- src/ui/handlers.py +24 -2
src/services/image.py
CHANGED
|
@@ -105,8 +105,9 @@ class ImageService:
|
|
| 105 |
tool_name="generate_image_edit_5",
|
| 106 |
parameters={
|
| 107 |
"prompt": edit_prompt,
|
| 108 |
-
"
|
| 109 |
-
"
|
|
|
|
| 110 |
},
|
| 111 |
on_progress=on_progress
|
| 112 |
)
|
|
|
|
| 105 |
tool_name="generate_image_edit_5",
|
| 106 |
parameters={
|
| 107 |
"prompt": edit_prompt,
|
| 108 |
+
"image": image_url, # Can be URL or base64 data URL
|
| 109 |
+
"width": 1024,
|
| 110 |
+
"height": 1024
|
| 111 |
},
|
| 112 |
on_progress=on_progress
|
| 113 |
)
|
src/services/video.py
CHANGED
|
@@ -93,8 +93,10 @@ class VideoService:
|
|
| 93 |
tool_name="generate_image_to_video_2",
|
| 94 |
parameters={
|
| 95 |
"prompt": motion_prompt,
|
| 96 |
-
"
|
| 97 |
-
"
|
|
|
|
|
|
|
| 98 |
},
|
| 99 |
on_progress=on_progress
|
| 100 |
)
|
|
|
|
| 93 |
tool_name="generate_image_to_video_2",
|
| 94 |
parameters={
|
| 95 |
"prompt": motion_prompt,
|
| 96 |
+
"image": image_url, # Can be URL or base64 data URL
|
| 97 |
+
"width": 720,
|
| 98 |
+
"height": 1280,
|
| 99 |
+
"fps": 24
|
| 100 |
},
|
| 101 |
on_progress=on_progress
|
| 102 |
)
|
src/ui/handlers.py
CHANGED
|
@@ -247,7 +247,18 @@ class Handlers:
|
|
| 247 |
asyncio.set_event_loop(loop)
|
| 248 |
|
| 249 |
try:
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
images = loop.run_until_complete(
|
| 253 |
service.edit_image(
|
|
@@ -339,7 +350,18 @@ class Handlers:
|
|
| 339 |
asyncio.set_event_loop(loop)
|
| 340 |
|
| 341 |
try:
|
| 342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
| 344 |
videos = loop.run_until_complete(
|
| 345 |
service.animate_image(
|
|
|
|
| 247 |
asyncio.set_event_loop(loop)
|
| 248 |
|
| 249 |
try:
|
| 250 |
+
# Convert local file to base64 data URL
|
| 251 |
+
import base64
|
| 252 |
+
import mimetypes
|
| 253 |
+
|
| 254 |
+
mime_type, _ = mimetypes.guess_type(input_image)
|
| 255 |
+
if not mime_type:
|
| 256 |
+
mime_type = "image/png"
|
| 257 |
+
|
| 258 |
+
with open(input_image, "rb") as f:
|
| 259 |
+
image_data = base64.b64encode(f.read()).decode("utf-8")
|
| 260 |
+
|
| 261 |
+
image_url = f"data:{mime_type};base64,{image_data}"
|
| 262 |
|
| 263 |
images = loop.run_until_complete(
|
| 264 |
service.edit_image(
|
|
|
|
| 350 |
asyncio.set_event_loop(loop)
|
| 351 |
|
| 352 |
try:
|
| 353 |
+
# Convert local file to base64 data URL
|
| 354 |
+
import base64
|
| 355 |
+
import mimetypes
|
| 356 |
+
|
| 357 |
+
mime_type, _ = mimetypes.guess_type(input_image)
|
| 358 |
+
if not mime_type:
|
| 359 |
+
mime_type = "image/png"
|
| 360 |
+
|
| 361 |
+
with open(input_image, "rb") as f:
|
| 362 |
+
image_data = base64.b64encode(f.read()).decode("utf-8")
|
| 363 |
+
|
| 364 |
+
image_url = f"data:{mime_type};base64,{image_data}"
|
| 365 |
|
| 366 |
videos = loop.run_until_complete(
|
| 367 |
service.animate_image(
|