Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,10 +179,6 @@
|
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
import gradio as gr
|
| 187 |
import torch
|
| 188 |
import numpy as np
|
|
@@ -239,14 +235,16 @@ def style_mixing_interface(image1, image2, mix_value):
|
|
| 239 |
def send_to_backend(image_buffer, user_id):
|
| 240 |
if not user_id:
|
| 241 |
return "❌ user_id not found."
|
|
|
|
|
|
|
| 242 |
|
| 243 |
try:
|
| 244 |
-
#
|
| 245 |
file_bytes = image_buffer.getvalue()
|
| 246 |
|
| 247 |
files = {'file': ('generated_image.png', file_bytes, 'image/png')}
|
| 248 |
|
| 249 |
-
#
|
| 250 |
url = f"https://5a4d-103-40-74-78.ngrok-free.app/customisation/upload/{user_id}"
|
| 251 |
|
| 252 |
response = requests.post(url, files=files)
|
|
@@ -288,7 +286,8 @@ with gr.Blocks(title="Style Mixing for Clothing Design") as iface:
|
|
| 288 |
result_image, buffer = style_mixing_interface(image1, image2, mix_value)
|
| 289 |
return result_image, buffer
|
| 290 |
|
| 291 |
-
|
|
|
|
| 292 |
save_button.click(send_to_backend, inputs=[image_buffer, user_id_state], outputs=[save_status])
|
| 293 |
|
| 294 |
iface.launch()
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
import gradio as gr
|
| 183 |
import torch
|
| 184 |
import numpy as np
|
|
|
|
| 235 |
def send_to_backend(image_buffer, user_id):
|
| 236 |
if not user_id:
|
| 237 |
return "❌ user_id not found."
|
| 238 |
+
if image_buffer is None:
|
| 239 |
+
return "⚠️ No image generated. Please mix styles first."
|
| 240 |
|
| 241 |
try:
|
| 242 |
+
# Convert BytesIO to raw bytes before sending
|
| 243 |
file_bytes = image_buffer.getvalue()
|
| 244 |
|
| 245 |
files = {'file': ('generated_image.png', file_bytes, 'image/png')}
|
| 246 |
|
| 247 |
+
# Update with your actual ngrok or server URL
|
| 248 |
url = f"https://5a4d-103-40-74-78.ngrok-free.app/customisation/upload/{user_id}"
|
| 249 |
|
| 250 |
response = requests.post(url, files=files)
|
|
|
|
| 286 |
result_image, buffer = style_mixing_interface(image1, image2, mix_value)
|
| 287 |
return result_image, buffer
|
| 288 |
|
| 289 |
+
mix_button = gr.Button("Mix Styles")
|
| 290 |
+
mix_button.click(mix_and_store, inputs=[image1_input, image2_input, mix_slider], outputs=[output_image, image_buffer])
|
| 291 |
save_button.click(send_to_backend, inputs=[image_buffer, user_id_state], outputs=[save_status])
|
| 292 |
|
| 293 |
iface.launch()
|