File size: 2,926 Bytes
00ebd80
 
3e75dc6
00ebd80
3e75dc6
 
 
 
 
 
 
00ebd80
 
3e75dc6
00ebd80
964392f
 
 
3e75dc6
964392f
3e75dc6
 
964392f
 
 
 
 
 
 
 
 
 
 
00ebd80
3e75dc6
00ebd80
5ea3481
 
 
 
 
 
00ebd80
 
 
b729574
 
00ebd80
 
 
5ea3481
 
 
 
 
 
 
 
 
 
 
 
00ebd80
5ea3481
00ebd80
 
 
 
5ea3481
 
 
 
 
00ebd80
 
964392f
b729574
3e75dc6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import gradio as gr
import torch
from diffusers import DiffusionPipeline

# Load the new model
# Use bfloat16 for speed and CUDA if available
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = DiffusionPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-dev", 
    dtype=torch.bfloat16,
    device_map=device
)

# Function to generate outfit image + suggestion
def generate_outfit(weather, activity, style):
    try:
        prompt = (
            f"A realistic full-body outfit for {weather} weather, "
            f"{activity} activity, {style} style, front view, fashion style, full body"
        )
        result = pipe(prompt)
        image = result.images[0]

        suggestion_text = (
            f"πŸ’‘ Suggested outfit for {weather} weather, {activity} activity, {style} style:\n"
            "- Top: light breathable shirt or jacket depending on weather\n"
            "- Bottom: comfortable pants or shorts\n"
            "- Shoes: suitable for activity\n"
            "- Accessories: hat, sunglasses, or scarf depending on weather"
        )
        return image, suggestion_text
    except Exception as e:
        return None, f"❌ Error generating outfit: {str(e)}"

# Gradio UI
custom_css = """
body {background: linear-gradient(135deg, #232526, #414345); color: white; font-family: 'Poppins', sans-serif;}
.gradio-container {max-width: 900px !important; margin: auto;}
h1,h2,h3 {text-align:center; color:#fff;}
.gr-button {background-color:#00bfa6 !important; color:white !important; font-weight:bold; border-radius:12px !important;}
.gr-button:hover {background-color:#007f70 !important;}
.gr-image {border-radius:12px; box-shadow:0 0 20px rgba(0,255,255,0.1);}
"""

with gr.Blocks(css=custom_css) as app:
    gr.Markdown("<h1 style='text-align:center;'>πŸ‘— ClothCast - AI Outfit Forecaster (Fast)</h1>")
    gr.Markdown("<p style='text-align:center;'>Select your weather, activity, and style to generate an AI outfit quickly!</p>")

    with gr.Row():
        with gr.Column(scale=1):
            weather = gr.Dropdown(
                ["Hot", "Cold", "Rainy", "Snowy", "Mild", "Humid"],
                label="🌀 Weather", value="Hot"
            )
            activity = gr.Dropdown(
                ["Casual", "Work", "Party", "Sporty"],
                label="πŸƒ Activity", value="Casual"
            )
            style = gr.Dropdown(
                ["Casual", "Sporty", "Formal"],
                label="🎨 Style", value="Casual"
            )
            generate_btn = gr.Button("Generate Outfit πŸ‘—", variant="primary")

        with gr.Column(scale=1):
            outfit_image = gr.Image(label="πŸ–Ό Generated Outfit")
            outfit_text = gr.Textbox(label="πŸ’‘ Outfit Suggestion", lines=8)

    generate_btn.click(
        generate_outfit, 
        inputs=[weather, activity, style], 
        outputs=[outfit_image, outfit_text]
    )

app.launch(share=True)