THEAIMART commited on
Commit
ecc0caa
β€’
1 Parent(s): 13e2080

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +250 -0
  2. ico.jpeg +0 -0
  3. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ import streamlit as st
3
+ import os
4
+ import google.generativeai as genai
5
+ import time
6
+ load_dotenv()
7
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
8
+ st.set_page_config(
9
+ page_title="Theaimart",
10
+ page_icon="ico.jpeg",
11
+ layout="wide",
12
+ initial_sidebar_state="expanded"
13
+ )
14
+
15
+ st.markdown("""
16
+ <style>
17
+ /* Main background and text colors */
18
+ .stApp {
19
+ background-color: #1a1a1a;
20
+ color: #ffffff;
21
+ }
22
+
23
+ /* Buttons */
24
+ .stButton>button {
25
+ background-color: #FF4B4B;
26
+ color: white;
27
+ border-radius: 8px;
28
+ padding: 0.5rem 1rem;
29
+ border: none;
30
+ transition: all 0.3s ease;
31
+ }
32
+ .stButton>button:hover {
33
+ background-color: #FF6B6B;
34
+ transform: translateY(-2px);
35
+ box-shadow: 0 4px 12px rgba(255, 75, 75, 0.2);
36
+ }
37
+
38
+ /* Headers */
39
+ h1, h2, h3 {
40
+ color: #FF4B4B !important;
41
+ font-weight: 600;
42
+ }
43
+
44
+ /* File uploader */
45
+ .uploadedFile {
46
+ background-color: #2d2d2d !important;
47
+ border-radius: 8px;
48
+ padding: 1rem;
49
+ border: 2px dashed #FF4B4B;
50
+ }
51
+
52
+ /* Select boxes */
53
+ .stSelectbox {
54
+ background-color: #2d2d2d;
55
+ border-radius: 8px;
56
+ color: white;
57
+ }
58
+
59
+ /* Text inputs */
60
+ .stTextInput>div>div>input {
61
+ background-color: #2d2d2d;
62
+ color: white;
63
+ border-radius: 8px;
64
+ border: 1px solid #FF4B4B;
65
+ }
66
+
67
+ /* Cards */
68
+ .css-1r6slb0 {
69
+ background-color: #2d2d2d;
70
+ border-radius: 10px;
71
+ padding: 1.5rem;
72
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
73
+ }
74
+
75
+ /* Multiselect */
76
+ .stMultiSelect {
77
+ background-color: #2d2d2d;
78
+ border-radius: 8px;
79
+ }
80
+
81
+ /* Success messages */
82
+ .success {
83
+ padding: 1rem;
84
+ border-radius: 8px;
85
+ background-color: #1e4620;
86
+ border-left: 4px solid #4CAF50;
87
+ }
88
+
89
+ /* Warning messages */
90
+ .warning {
91
+ padding: 1rem;
92
+ border-radius: 8px;
93
+ background-color: #332b1b;
94
+ border-left: 4px solid #FFC107;
95
+ }
96
+
97
+ /* Redirect message */
98
+ .redirect-message {
99
+ position: fixed;
100
+ bottom: 20px;
101
+ right: 20px;
102
+ background-color: #2d2d2d;
103
+ padding: 1rem;
104
+ border-radius: 8px;
105
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
106
+ z-index: 1000;
107
+ }
108
+ .social-links a {
109
+ display: block;
110
+ margin: 0.5rem 0;
111
+ padding: 0.8rem 1.2rem;
112
+ color: white;
113
+ text-decoration: none;
114
+ border-radius: 8px;
115
+ text-align: center;
116
+ font-weight: bold;
117
+ background-color: #FF4B4B; /* Button background */
118
+ transition: all 0.3s ease;
119
+ }
120
+ .social-links a:hover {
121
+ background-color: #FF6B6B; /* Hover effect */
122
+ transform: translateY(-3px);
123
+ box-shadow: 0 4px 12px rgba(255, 75, 75, 0.3);
124
+ }
125
+
126
+ </style>
127
+ """, unsafe_allow_html=True)
128
+
129
+
130
+ def input_image_setup(uploaded_file):
131
+ if uploaded_file is not None:
132
+ bytes_data = uploaded_file.getvalue()
133
+ image_parts = [
134
+ {
135
+ "mime_type": uploaded_file.type,
136
+ "data": bytes_data
137
+ }
138
+ ]
139
+ return image_parts
140
+ else:
141
+ raise FileNotFoundError("No file uploaded")
142
+
143
+
144
+ def get_fashion_analysis(image, prompt):
145
+ try:
146
+ model = genai.GenerativeModel('gemini-1.5-flash')
147
+ if image:
148
+ response = model.generate_content([image[0], prompt])
149
+ else:
150
+ response = model.generate_content([prompt])
151
+ return response.text
152
+ except Exception as e:
153
+ st.error(f"Analysis failed: {str(e)}")
154
+ return None
155
+
156
+
157
+ with st.sidebar:
158
+ st.image("ico.jpeg", width=100)
159
+ st.title("FashChat Settings")
160
+
161
+ accent_color = st.color_picker("Accent Color", "#FF4B4B")
162
+ st.markdown("---")
163
+ st.markdown("### About FashChat")
164
+ st.markdown(
165
+ "Your AI-powered fashion analysis companion. Get instant insights on outfits, makeup, and celebrity styles.")
166
+
167
+ st.markdown("---")
168
+ st.markdown("v1.0.0 | Made with ❀️ by theaimart")
169
+
170
+ st.title("FashChat: Your Fashion AI Companion")
171
+
172
+ analysis_type = st.tabs(["Outfit Analyzer"])
173
+
174
+ with analysis_type[0]:
175
+ st.header("🎭 Outfit Analysis")
176
+
177
+ col1, col2 = st.columns([2, 1])
178
+
179
+ with col1:
180
+ uploaded_file = st.file_uploader(
181
+ "Drop your outfit image here",
182
+ type=["jpg", "jpeg", "png"],
183
+ help="Upload a clear, full-body image for best results"
184
+ )
185
+
186
+ if uploaded_file:
187
+ st.image(uploaded_file, use_column_width=True)
188
+
189
+ with col2:
190
+ prompt = st.text_area("Analysis Focus (optional)",
191
+ placeholder="E.g., 'Analyze the color coordination' or 'Suggest improvements'")
192
+
193
+ analysis_options = st.multiselect(
194
+ "Analysis Aspects",
195
+ [
196
+ "🎨 Color Harmony",
197
+ "πŸ“ Fit Analysis",
198
+ "🎯 Style Recommendations",
199
+ "πŸ›οΈ Shopping Suggestions",
200
+ "πŸ”„ Mix & Match Ideas"
201
+ ],
202
+ default=["🎨 Color Harmony"]
203
+ )
204
+
205
+ analyze_button = st.button("✨ Analyze Outfit", type="primary")
206
+
207
+ if analyze_button and uploaded_file:
208
+ with st.spinner("Analyzing your outfit..."):
209
+ try:
210
+ image_data = input_image_setup(uploaded_file)
211
+ input_prompt = f"""
212
+ As a fashion expert, provide a detailed analysis of this outfit:
213
+
214
+ Focus areas:
215
+ {', '.join(analysis_options)}
216
+
217
+ Additional context:
218
+ {prompt if prompt else 'Provide general style analysis'}
219
+
220
+ Please structure the analysis with clear headings and bullet points.
221
+ """
222
+
223
+ response = get_fashion_analysis(image=image_data, prompt=input_prompt)
224
+
225
+ st.markdown("### πŸ“‹ Analysis Results")
226
+ st.markdown(response)
227
+
228
+ st.markdown("""
229
+ <div class='success'>
230
+ Analysis completed successfully! Save or share your results.
231
+ </div>
232
+ """, unsafe_allow_html=True)
233
+
234
+ st.markdown("""
235
+ <div class='redirect-message'>
236
+ FashChat by theaimart
237
+ </div>
238
+ """, unsafe_allow_html=True)
239
+
240
+ time.sleep(3)
241
+
242
+ except Exception as e:
243
+ st.error(f"Analysis failed: {str(e)}")
244
+ # Footer
245
+ st.markdown("---")
246
+ col1, col2, col3 = st.columns(3)
247
+ with col1:
248
+ st.markdown("### πŸ“± Connect")
249
+ st.markdown("[Instagram](https://instagram.com)")
250
+ st.markdown("[Youtube](https://www.youtube.com/@theaimartofficial)")
ico.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ streamlit
2
+ google-generativeai
3
+ python-dotenv
4
+ langchain
5
+ langchain_google_genai
6
+ Pillow