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(""" """, 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("""
Analysis completed successfully! Save or share your results.
""", unsafe_allow_html=True) st.markdown("""
FashChat by theaimart
""", 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)")