Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -292,36 +292,88 @@ def send_to_backend(image_buffer, user_id):
|
|
| 292 |
|
| 293 |
|
| 294 |
# Gradio interface
|
| 295 |
-
with gr.Blocks(title="Style Mixing for Clothing Designs") as iface:
|
| 296 |
-
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
|
| 303 |
-
|
| 304 |
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
|
| 309 |
-
|
| 310 |
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
image_buffer = gr.State()
|
| 316 |
-
save_status = gr.Textbox(label="Save Status", interactive=False)
|
| 317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
def mix_and_store(image1, image2, mix_value):
|
| 319 |
result_image, buffer = style_mixing_interface(image1, image2, mix_value)
|
| 320 |
return result_image, buffer
|
| 321 |
|
| 322 |
-
|
| 323 |
-
mix_button.click(
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
iface.launch()
|
| 327 |
|
|
|
|
|
|
| 292 |
|
| 293 |
|
| 294 |
# Gradio interface
|
| 295 |
+
# with gr.Blocks(title="Style Mixing for Clothing Designs") as iface:
|
| 296 |
+
# user_id_state = gr.State()
|
| 297 |
|
| 298 |
+
# @iface.load(inputs=None, outputs=[user_id_state])
|
| 299 |
+
# def on_load(request: gr.Request):
|
| 300 |
+
# user_id = request.query_params.get('user_id', '')
|
| 301 |
+
# return user_id
|
| 302 |
|
| 303 |
+
# gr.Markdown("## Style Mixing for Clothing Design\nUpload two projected clothing images and mix their styles.")
|
| 304 |
|
| 305 |
+
# with gr.Row():
|
| 306 |
+
# image1_input = gr.Image(label="First Clothing Image", type="filepath")
|
| 307 |
+
# image2_input = gr.Image(label="Second Clothing Image", type="filepath")
|
| 308 |
|
| 309 |
+
# mix_slider = gr.Slider(label="Style Mixing Strength", minimum=0, maximum=9, step=1, value=5)
|
| 310 |
|
| 311 |
+
# with gr.Row():
|
| 312 |
+
# output_image = gr.Image(label="Mixed Clothing Design")
|
| 313 |
+
# save_button = gr.Button("Download & Save to Database")
|
| 314 |
|
| 315 |
+
# image_buffer = gr.State()
|
| 316 |
+
# save_status = gr.Textbox(label="Save Status", interactive=False)
|
| 317 |
+
|
| 318 |
+
# def mix_and_store(image1, image2, mix_value):
|
| 319 |
+
# result_image, buffer = style_mixing_interface(image1, image2, mix_value)
|
| 320 |
+
# return result_image, buffer
|
| 321 |
+
|
| 322 |
+
# mix_button = gr.Button("Mix Styles")
|
| 323 |
+
# mix_button.click(mix_and_store, inputs=[image1_input, image2_input, mix_slider], outputs=[output_image, image_buffer])
|
| 324 |
+
# save_button.click(send_to_backend, inputs=[image_buffer, user_id_state], outputs=[save_status])
|
| 325 |
+
|
| 326 |
+
# iface.launch()
|
| 327 |
+
import gradio as gr
|
| 328 |
+
|
| 329 |
+
with gr.Blocks(title="Style Mixing for Clothing Designs") as iface:
|
| 330 |
+
user_id_state = gr.State()
|
| 331 |
image_buffer = gr.State()
|
|
|
|
| 332 |
|
| 333 |
+
# Load user ID from URL
|
| 334 |
+
@iface.load(inputs=None, outputs=[user_id_state])
|
| 335 |
+
def on_load(request: gr.Request):
|
| 336 |
+
user_id = request.query_params.get('user_id', '')
|
| 337 |
+
return user_id
|
| 338 |
+
|
| 339 |
+
# Header
|
| 340 |
+
gr.Markdown("## 🎨 Style Mixing for Clothing Designs")
|
| 341 |
+
gr.Markdown("Upload two projected clothing images and blend their styles using the slider below.")
|
| 342 |
+
|
| 343 |
+
# Upload Inputs
|
| 344 |
+
with gr.Group():
|
| 345 |
+
with gr.Row():
|
| 346 |
+
image1_input = gr.Image(label="👗 First Clothing Image", type="filepath")
|
| 347 |
+
image2_input = gr.Image(label="👗 Second Clothing Image", type="filepath")
|
| 348 |
+
mix_slider = gr.Slider(label="🧪 Style Mixing Intensity", minimum=0, maximum=9, step=1, value=5, info="0 = Mostly Left | 9 = Mostly Right")
|
| 349 |
+
|
| 350 |
+
# Output & Actions
|
| 351 |
+
with gr.Group():
|
| 352 |
+
with gr.Row():
|
| 353 |
+
output_image = gr.Image(label="🧵 Mixed Clothing Design")
|
| 354 |
+
with gr.Row():
|
| 355 |
+
mix_button = gr.Button("✨ Mix Styles")
|
| 356 |
+
save_button = gr.Button("💾 Save to Database")
|
| 357 |
+
save_status = gr.Textbox(label="Status", interactive=False)
|
| 358 |
+
|
| 359 |
+
# Functions
|
| 360 |
def mix_and_store(image1, image2, mix_value):
|
| 361 |
result_image, buffer = style_mixing_interface(image1, image2, mix_value)
|
| 362 |
return result_image, buffer
|
| 363 |
|
| 364 |
+
# Button Logic
|
| 365 |
+
mix_button.click(
|
| 366 |
+
fn=mix_and_store,
|
| 367 |
+
inputs=[image1_input, image2_input, mix_slider],
|
| 368 |
+
outputs=[output_image, image_buffer]
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
save_button.click(
|
| 372 |
+
fn=send_to_backend,
|
| 373 |
+
inputs=[image_buffer, user_id_state],
|
| 374 |
+
outputs=[save_status]
|
| 375 |
+
)
|
| 376 |
|
| 377 |
iface.launch()
|
| 378 |
|
| 379 |
+
|