import gradio as gr import tensorflow as tf import numpy as np from PIL import Image # Load the trained model model = tf.keras.models.load_model("fashion_classifier_model.keras") # Class labels and tips class_names = ['casual', 'formal', 'party', 'sporty', 'traditional'] tips = { "casual": "๐Ÿ’ก Add a denim jacket or crossbody bag to glow up your everyday look.", "formal": "๐Ÿ’ก Blazers + sleek ponytail = Powerhouse vibes.", "party": "๐Ÿ’ก Bold lips or glitter heels will steal the spotlight.", "sporty": "๐Ÿ’ก Pair it with sneakers, a cap, and bold energy.", "traditional": "๐Ÿ’ก Colorful bangles or a bright dupatta will complete your ethnic glam." } # Prediction function (filepath version for mobile upload fix) def predict_style(image_path): image = Image.open(image_path).resize((224, 224)).convert("RGB") image_array = np.expand_dims(np.array(image) / 255.0, axis=0) prediction = model.predict(image_array) index = np.argmax(prediction) label = class_names[index].upper() confidence = prediction[0][index] * 100 result = f"

๐Ÿ‘‘ Your Style Match: {label}

๐Ÿ“Š Confidence: {confidence:.2f}%

" style_tip = f"
{tips[class_names[index]]}
" return result, style_tip # Gradio interface with gr.Blocks(css=""" .result-box { background-color: #fff0f5; border: 2px solid #ffa5ba; border-radius: 16px; padding: 20px; text-align: center; margin-top: 10px; font-size: 18px; } .tip-box { background-color: #fffafc; border-left: 6px solid #ff69b4; padding: 16px; margin-top: 10px; font-style: italic; font-size: 16px; } h1 { color: #d63384; text-align: center; font-size: 36px; } body, .gradio-container { background: linear-gradient(to bottom, #fdf2f8, #ffffff); } .description { background-color: #fff8fc; border-left: 5px solid #ff69b4; padding: 14px; margin: 15px 0 30px 0; font-size: 16px; color: #a83279; } """) as demo: gr.Markdown("# ๐ŸŽ€ FashionVision AI ๐Ÿ‘ ") gr.Markdown("""
โœจ FashionVision AI is your personal **women's fashion stylist** powered by AI. Upload your outfit photo and let our model classify your style into: Casual, Formal, Party, Sporty, or Traditional looks. Ideal for digital wardrobes, e-commerce previews, or just having fun with your style! ๐Ÿ’ƒ๐Ÿ‘—
""") with gr.Row(): with gr.Column(): img = gr.Image(label="๐Ÿ“ธ Upload your outfit (for women)", type="filepath", image_mode="RGB") btn = gr.Button("โœจ Detect My Style") with gr.Column(): result = gr.HTML() tip = gr.HTML() btn.click(predict_style, inputs=img, outputs=[result, tip]) gr.Markdown("---") gr.Markdown("

๐Ÿงต Made with ๐Ÿ’– by Subata | Powered by TensorFlow + Gradio

") demo.launch()