Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,32 +3,29 @@ from PIL import Image
|
|
| 3 |
import os
|
| 4 |
# Import your core functions (estimate_pose, segment_clothing, inpaint_clothing, change_clothing) from your main script
|
| 5 |
from main_code_script import change_clothing # Replace your_main_script
|
| 6 |
-
|
| 7 |
-
def predict(image_path, clothing_prompt):
|
| 8 |
"""
|
| 9 |
The prediction function for Gradio.
|
| 10 |
"""
|
| 11 |
try:
|
| 12 |
-
modified_image = change_clothing(image_path,
|
| 13 |
if modified_image:
|
| 14 |
return modified_image
|
| 15 |
else:
|
| 16 |
-
return "Failed to change clothing.
|
| 17 |
except Exception as e:
|
| 18 |
return f"Error: {e}"
|
| 19 |
-
|
| 20 |
# Create the Gradio interface
|
| 21 |
iface = gr.Interface(
|
| 22 |
fn=predict,
|
| 23 |
inputs=[
|
| 24 |
-
gr.Image(type="filepath", label="Input Image"),
|
| 25 |
-
gr.
|
| 26 |
],
|
| 27 |
outputs=gr.Image(type="pil", label="Modified Image"),
|
| 28 |
title="AI Clothing Changer",
|
| 29 |
-
description="Try on different clothes with AI!",
|
| 30 |
)
|
| 31 |
-
|
| 32 |
# Launch the Gradio interface
|
| 33 |
if __name__ == "__main__":
|
| 34 |
iface.launch()
|
|
|
|
| 3 |
import os
|
| 4 |
# Import your core functions (estimate_pose, segment_clothing, inpaint_clothing, change_clothing) from your main script
|
| 5 |
from main_code_script import change_clothing # Replace your_main_script
|
| 6 |
+
def predict(image_path, garment_image_path): # Changed input
|
|
|
|
| 7 |
"""
|
| 8 |
The prediction function for Gradio.
|
| 9 |
"""
|
| 10 |
try:
|
| 11 |
+
modified_image = change_clothing(image_path, garment_image_path) # Changed input
|
| 12 |
if modified_image:
|
| 13 |
return modified_image
|
| 14 |
else:
|
| 15 |
+
return "Failed to change clothing. Please check the images."
|
| 16 |
except Exception as e:
|
| 17 |
return f"Error: {e}"
|
|
|
|
| 18 |
# Create the Gradio interface
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=predict,
|
| 21 |
inputs=[
|
| 22 |
+
gr.Image(type="filepath", label="Input Image (Person)"), # Changed label
|
| 23 |
+
gr.Image(type="filepath", label="Garment Image"), # Added input
|
| 24 |
],
|
| 25 |
outputs=gr.Image(type="pil", label="Modified Image"),
|
| 26 |
title="AI Clothing Changer",
|
| 27 |
+
description="Try on different clothes with AI by uploading a garment image!", # Changed description
|
| 28 |
)
|
|
|
|
| 29 |
# Launch the Gradio interface
|
| 30 |
if __name__ == "__main__":
|
| 31 |
iface.launch()
|