Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the fashion recommendation model from Hugging Face
|
| 5 |
+
model = pipeline("image-classification", model="your-huggingface-model")
|
| 6 |
+
|
| 7 |
+
def recommend_outfit(image, style_pref, body_type):
|
| 8 |
+
predictions = model(image)
|
| 9 |
+
|
| 10 |
+
# Mockup of recommended outfits based on predictions and user preferences
|
| 11 |
+
recommended_outfits = ["outfit1.jpg", "outfit2.jpg", "outfit3.jpg"] # Replace with actual logic
|
| 12 |
+
|
| 13 |
+
return predictions, recommended_outfits
|
| 14 |
+
|
| 15 |
+
def feedback(outfit_image, like):
|
| 16 |
+
if like == "Like":
|
| 17 |
+
return "Thank you for your feedback!"
|
| 18 |
+
else:
|
| 19 |
+
return "We appreciate your input!"
|
| 20 |
+
|
| 21 |
+
# Define Gradio interface for outfit recommendation
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=recommend_outfit,
|
| 24 |
+
inputs=[
|
| 25 |
+
gr.inputs.Image(type="pil"),
|
| 26 |
+
gr.inputs.Textbox(label="Style Preferences"),
|
| 27 |
+
gr.inputs.Textbox(label="Body Type")
|
| 28 |
+
],
|
| 29 |
+
outputs=[
|
| 30 |
+
gr.outputs.Label(num_top_classes=3),
|
| 31 |
+
gr.outputs.Image(type="filepath", label="Recommended Outfits")
|
| 32 |
+
],
|
| 33 |
+
title="ChicAI: Your AI-Powered Virtual Stylist",
|
| 34 |
+
description="Upload an image of your clothing to get outfit recommendations based on current trends."
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
# Define Gradio interface for feedback mechanism
|
| 38 |
+
feedback_interface = gr.Interface(
|
| 39 |
+
fn=feedback,
|
| 40 |
+
inputs=[
|
| 41 |
+
gr.inputs.Image(type="filepath", label="Outfit Image"),
|
| 42 |
+
gr.inputs.Radio(["Like", "Dislike"], label="Did you like this outfit?")
|
| 43 |
+
],
|
| 44 |
+
outputs="text"
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
# Launch both interfaces (you may want to integrate them better in a real app)
|
| 48 |
+
iface.launch()
|
| 49 |
+
feedback_interface.launch()
|