File size: 7,191 Bytes
ecc0caa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
from dotenv import load_dotenv
import streamlit as st
import os
import google.generativeai as genai
import time
load_dotenv()
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
st.set_page_config(
    page_title="Theaimart",
    page_icon="ico.jpeg",
    layout="wide",
    initial_sidebar_state="expanded"
)

st.markdown("""
    <style>
        /* Main background and text colors */
        .stApp {
            background-color: #1a1a1a;
            color: #ffffff;
        }

        /* Buttons */
        .stButton>button {
            background-color: #FF4B4B;
            color: white;
            border-radius: 8px;
            padding: 0.5rem 1rem;
            border: none;
            transition: all 0.3s ease;
        }
        .stButton>button:hover {
            background-color: #FF6B6B;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(255, 75, 75, 0.2);
        }

        /* Headers */
        h1, h2, h3 {
            color: #FF4B4B !important;
            font-weight: 600;
        }

        /* File uploader */
        .uploadedFile {
            background-color: #2d2d2d !important;
            border-radius: 8px;
            padding: 1rem;
            border: 2px dashed #FF4B4B;
        }

        /* Select boxes */
        .stSelectbox {
            background-color: #2d2d2d;
            border-radius: 8px;
            color: white;
        }

        /* Text inputs */
        .stTextInput>div>div>input {
            background-color: #2d2d2d;
            color: white;
            border-radius: 8px;
            border: 1px solid #FF4B4B;
        }

        /* Cards */
        .css-1r6slb0 {
            background-color: #2d2d2d;
            border-radius: 10px;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        /* Multiselect */
        .stMultiSelect {
            background-color: #2d2d2d;
            border-radius: 8px;
        }

        /* Success messages */
        .success {
            padding: 1rem;
            border-radius: 8px;
            background-color: #1e4620;
            border-left: 4px solid #4CAF50;
        }

        /* Warning messages */
        .warning {
            padding: 1rem;
            border-radius: 8px;
            background-color: #332b1b;
            border-left: 4px solid #FFC107;
        }

        /* Redirect message */
        .redirect-message {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #2d2d2d;
            padding: 1rem;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
            z-index: 1000;
        }
        .social-links a {
            display: block;
            margin: 0.5rem 0;
            padding: 0.8rem 1.2rem;
            color: white;
            text-decoration: none;
            border-radius: 8px;
            text-align: center;
            font-weight: bold;
            background-color: #FF4B4B; /* Button background */
            transition: all 0.3s ease;
        }
        .social-links a:hover {
            background-color: #FF6B6B; /* Hover effect */
            transform: translateY(-3px);
            box-shadow: 0 4px 12px rgba(255, 75, 75, 0.3);
        }
    
    </style>
""", unsafe_allow_html=True)


def input_image_setup(uploaded_file):
    if uploaded_file is not None:
        bytes_data = uploaded_file.getvalue()
        image_parts = [
            {
                "mime_type": uploaded_file.type,
                "data": bytes_data
            }
        ]
        return image_parts
    else:
        raise FileNotFoundError("No file uploaded")


def get_fashion_analysis(image, prompt):
    try:
        model = genai.GenerativeModel('gemini-1.5-flash')
        if image:
            response = model.generate_content([image[0], prompt])
        else:
            response = model.generate_content([prompt])
        return response.text
    except Exception as e:
        st.error(f"Analysis failed: {str(e)}")
        return None


with st.sidebar:
    st.image("ico.jpeg", width=100)
    st.title("FashChat Settings")

    accent_color = st.color_picker("Accent Color", "#FF4B4B")
    st.markdown("---")
    st.markdown("### About FashChat")
    st.markdown(
        "Your AI-powered fashion analysis companion. Get instant insights on outfits, makeup, and celebrity styles.")

    st.markdown("---")
    st.markdown("v1.0.0 | Made with ❀️ by theaimart")

st.title("FashChat: Your Fashion AI Companion")

analysis_type = st.tabs(["Outfit Analyzer"])

with analysis_type[0]:
    st.header("🎭 Outfit Analysis")

    col1, col2 = st.columns([2, 1])

    with col1:
        uploaded_file = st.file_uploader(
            "Drop your outfit image here",
            type=["jpg", "jpeg", "png"],
            help="Upload a clear, full-body image for best results"
        )

        if uploaded_file:
            st.image(uploaded_file, use_column_width=True)

    with col2:
        prompt = st.text_area("Analysis Focus (optional)",
                              placeholder="E.g., 'Analyze the color coordination' or 'Suggest improvements'")

        analysis_options = st.multiselect(
            "Analysis Aspects",
            [
                "🎨 Color Harmony",
                "πŸ“ Fit Analysis",
                "🎯 Style Recommendations",
                "πŸ›οΈ Shopping Suggestions",
                "πŸ”„ Mix & Match Ideas"
            ],
            default=["🎨 Color Harmony"]
        )

        analyze_button = st.button("✨ Analyze Outfit", type="primary")

    if analyze_button and uploaded_file:
        with st.spinner("Analyzing your outfit..."):
            try:
                image_data = input_image_setup(uploaded_file)
                input_prompt = f"""
                As a fashion expert, provide a detailed analysis of this outfit:

                Focus areas:
                {', '.join(analysis_options)}

                Additional context:
                {prompt if prompt else 'Provide general style analysis'}

                Please structure the analysis with clear headings and bullet points.
                """

                response = get_fashion_analysis(image=image_data, prompt=input_prompt)

                st.markdown("### πŸ“‹ Analysis Results")
                st.markdown(response)

                st.markdown("""
                    <div class='success'>
                        Analysis completed successfully! Save or share your results.
                    </div>
                """, unsafe_allow_html=True)

                st.markdown("""
                    <div class='redirect-message'>
                        FashChat by theaimart
                    </div>
                """, unsafe_allow_html=True)

                time.sleep(3)

            except Exception as e:
                st.error(f"Analysis failed: {str(e)}")
# Footer
st.markdown("---")
col1, col2, col3 = st.columns(3)
with col1:
    st.markdown("### πŸ“± Connect")
    st.markdown("[Instagram](https://instagram.com)")
    st.markdown("[Youtube](https://www.youtube.com/@theaimartofficial)")