Create SkinGenius AI , web tool that builds personalized skin reports in 4 steps: Basic Info : Age, gender (optional), skin concerns (dropdown), current routine (text). Symptoms : Facial map + stinging/allergy checkboxes. Photos : Front/side selfies with AI feedback (e.g., “Too dark”). Lifestyle : Water, stress, sun exposure. Report output (dummy): Page 1 : Skin score (72/100) + insights (“Moderate dehydration”). Page 2 : Product picks (CeraVe , The Ordinary ) + weekly routine. Page 3 : Medical alerts (“See dermatologist if redness lasts >2 weeks”).
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
import plotly.graph_objects as go
from PIL import Image
import io
# Configure page
st.set_page_config(page_title="SkinGenius AI", page_icon="🧴", layout="wide")
# Initialize session state
if 'current_step' not in st.session_state:
st.session_state.current_step = 1
if 'user_data' not in st.session_state:
st.session_state.user_data = {}
def reset_form():
st.session_state.current_step = 1
st.session_state.user_data = {}
def next_step():
if st.session_state.current_step < 5:
st.session_state.current_step += 1
def prev_step():
if st.session_state.current_step > 1:
st.session_state.current_step -= 1
# Header
st.title("🧴 SkinGenius AI")
st.markdown("*Build your personalized skin report in 4 simple steps*")
# Progress bar
progress = (st.session_state.current_step - 1) / 4
st.progress(progress)
# Step indicators
steps = ["Basic Info", "Symptoms", "Photos", "Lifestyle", "Report"]
cols = st.columns(5)
for i, step in enumerate(steps):
with cols[i]:
if i + 1 == st.session_state.current_step:
st.markdown(f"**{i+1}. {step}** ✅")
elif i + 1 < st.session_state.current_step:
st.markdown(f"{i+1}. {step} ✅")
else:
st.markdown(f"{i+1}. {step}")
st.markdown("---")
# Step 1: Basic Info
if st.session_state.current_step == 1:
st.header("1. Basic Information")
col1, col2 = st.columns(2)
with col1:
age = st.number_input("Age", min_value=13, max_value=100, value=25)
gender = st.selectbox("Gender (Optional)", ["Prefer not to say", "Female", "Male", "Non-binary"])
skin_concerns = st.multiselect(
"Primary Skin Concerns",
["Acne", "Dryness", "Oily Skin", "Sensitivity", "Aging", "Dark Spots", "Redness", "Large Pores", "Uneven Texture"]
)
with col2:
current_routine = st.text_area(
"Current Skincare Routine",
placeholder="Describe your current morning and evening routine...",
height=150
)
if st.button("Next: Symptoms Analysis", type="primary"):
st.session_state.user_data.update({
'age': age,
'gender': gender,
'skin_concerns': skin_concerns,
'current_routine': current_routine
})
next_step()
st.rerun()
# Step 2: Symptoms
elif st.session_state.current_step == 2:
st.header("2. Symptoms Analysis")
col1, col2 = st.columns([2, 1])
with col1:
st.subheader("Facial Mapping")
st.markdown("Select areas where you experience skin issues:")
# Create a simple facial map using checkboxes
face_areas = {
"Forehead": st.checkbox("Forehead"),
"T-Zone": st.checkbox("T-Zone (Nose & Center)"),
"Cheeks": st.checkbox("Cheeks"),
"Under Eyes": st.checkbox("Under Eyes"),
"Jawline": st.checkbox("Jawline"),
"Chin": st.checkbox("Chin"),
"Neck": st.checkbox("Neck")
}
with col2:
st.subheader("Additional Symptoms")
symptoms = {
"stinging": st.checkbox("Stinging/Burning sensation"),
"itching": st.checkbox("Itching"),
"tightness": st.checkbox("Skin feels tight"),
"flaking": st.checkbox("Flaking/Peeling"),
"redness": st.checkbox("Persistent redness"),
"allergic_reactions": st.checkbox("Allergic reactions to products")
}
col1, col2 = st.columns(2)
with col1:
if st.button("← Previous"):
prev_step()
st.rerun()
with col2:
if st.button("Next: Photo Analysis", type="primary"):
st.session_state.user_data.update({
'face_areas': face_areas,
'symptoms': symptoms
})
next_step()
st.rerun()
# Step 3: Photos
elif st.session_state.current_step == 3:
st.header("3. Photo Analysis")
col1, col2 = st.columns(2)
with col1:
st.subheader("Front View")
front_photo = st.file_uploader("Upload front-facing photo", type=['png', 'jpg', 'jpeg'], key="front")
if front_photo:
image = Image.open(front_photo)
st.image(image, caption="Front view", use_column_width=True)
# Simulate AI feedback
feedback_messages = [
"✅ Good lighting detected",
"⚠️ Image slightly blurry - try holding phone steadier",
"✅ Face clearly visible",
"💡 Tip: Remove makeup for better analysis"
]
st.markdown("**AI Feedback:**")
for msg in feedback_messages:
st.markdown(f"- {msg}")
with col2:
st.subheader("Side View")
side_photo = st.file_uploader("Upload side profile photo", type=['png', 'jpg', 'jpeg'], key="side")
if side_photo:
image = Image.open(side_photo)
st.image(image, caption="Side view", use_column_width=True)
# Simulate AI feedback
feedback_messages = [
"✅ Good angle captured",
"⚠️ Too dark - try better lighting",
"✅ Skin texture visible",
"💡 Natural lighting works best"
]
st.markdown("**AI Feedback:**")
for msg in feedback_messages:
st.markdown(f"- {msg}")
st.info("📸 For best results: Use natural lighting, clean face, and hold camera steady")
col1, col2 = st.columns(2)
with col1:
if st.button("← Previous"):
prev_step()
st.rerun()
with col2:
if st.button("Next: Lifestyle", type="primary"):
st.session_state.user_data.update({
'front_photo': front_photo is not None,
'side_photo': side_photo is not None
})
next_step()
st.rerun()
# Step 4: Lifestyle
elif st.session_state.current_step == 4:
st.header("4. Lifestyle Factors")
col1, col2 = st.columns(2)
with col1:
st.subheader("Hydration & Health")
water_intake = st.slider("Daily water intake (glasses)", 1, 15, 6)
sleep_hours = st.slider("Average sleep hours", 4, 12, 7)
stress_level = st.select_slider("Stress level", options=["Low", "Moderate", "High"], value="Moderate")
with col2:
st.subheader("Environmental Factors")
sun_exposure = st.select_slider("Daily sun exposure", options=["Minimal", "Moderate", "High"], value="Moderate")
sunscreen_use = st.radio("Sunscreen usage", ["Never", "Sometimes", "Daily"])
environment = st.selectbox("Living environment", ["Urban", "Suburban", "Rural", "Coastal"])
st.subheader("Additional Factors")
col1, col2, col3 = st.columns(3)
with col1:
exercise_freq = st.selectbox("Exercise frequency", ["Rarely", "1-2x/week", "3-4x/week", "Daily"])
with col2:
diet_type = st.selectbox("Diet type", ["Standard", "Vegetarian", "Vegan", "Keto", "Mediterranean"])
with col3:
hormonal_changes = st.checkbox("Experiencing hormonal changes")
col1, col2 = st.columns(2)
with col1:
if st.button("← Previous"):
prev_step()
st.rerun()
with col2:
if st.button("Generate Report", type="primary"):
st.session_state.user_data.update({
'water_intake': water_intake,
'sleep_hours': sleep_hours,
'stress_level': stress_level,
'sun_exposure': sun_exposure,
'sunscreen_use': sunscreen_use,
'environment': environment,
'exercise_freq': exercise_freq,
'diet_type': diet_type,
'hormonal_changes': hormonal_changes
})
next_step()
st.rerun()
# Step 5: Report
elif st.session_state.current_step == 5:
st.header("📊 Your Personalized Skin Report")
# Generate dummy skin score based on inputs
base_score = 75
# Adjust score based on inputs
if st.session_state.user_data.get('water_intake', 6) < 4:
base_score -= 10
if st.session_state.user_data.get('sunscreen_use') == 'Never':
base_score -= 15
if st.session_state.user_data.get('stress_level') == 'High':
base_score -= 8
if st.session_state.user_data.get('sleep_hours', 7) < 6:
base_score -= 5
skin_score = max(40, min(95, base_score))
# Report tabs
tab1, tab2, tab3 = st.tabs(["Skin Analysis", "Product Recommendations", "Medical Insights"])
with tab1:
st.subheader("Your Skin Score")
# Create gauge chart
fig = go.Figure(go.Indicator(
mode = "gauge+number+delta",
value = skin_score,
domain = {'x': [0, 1], 'y': [0, 1]},
title = {'text': "Skin Health Score"},
delta = {'reference': 80},
gauge = {
'axis': {'range': [None, 100]},
'bar': {'color': "darkblue"},
'steps': [
{'range': [0, 50], 'color': "lightgray"},
{'range': [50, 80], 'color': "yellow"},
{'range': [80, 100], 'color': "green"}
],
'threshold': {
'line': {'color': "red", 'width': 4},
'thickness': 0.75,
'value': 90
}
}
))
fig.update_layout(height=300)
st.plotly_chart(fig, use_container_width=True)
# Insights
st.subheader("Key Insights")
insights = []
if st.session_state.user_data.get('water_intake', 6) < 6:
insights.append("🔹 **Moderate dehydration detected** - Consider increasing water intake")
if 'Dryness' in st.session_state.user_data.get('skin_concerns', []):
insights.append("🔹 **Dry skin concerns** - Focus on hydrating ingredients")
if 'Acne' in st.session_state.user_data.get('skin_concerns', []):
insights.append("🔹 **Acne-prone skin** - Gentle, non-comedogenic products recommended")
if st.session_state.user_data.get('sunscreen_use') != 'Daily':
insights.append("🔹 **Sun protection gap** - Daily SPF is crucial for skin health")
if not insights:
insights.append("🔹 **Good overall skin health** - Maintain current routine with minor optimizations")
for insight in insights:
st.markdown(insight)
with tab2:
st.subheader("Personalized Product Recommendations")
# Morning routine
st.markdown("### 🌅 Morning Routine")
morning_products = [
{"step": "1. Cleanser", "product": "CeraVe Foaming Facial Cleanser", "price": "$12.99"},
{"step": "2. Serum", "product": "The Ordinary Niacinamide 10% + Zinc 1%", "price": "$7.90"},
{"step": "3. Moisturizer", "product": "CeraVe Daily Moisturizing Lotion", "price": "$16.99"},
{"step": "4. Sunscreen", "product": "EltaMD UV Clear Broad-Spectrum SPF 46", "price": "$37.00"}
]
for product in morning_products:
col1, col2, col3 = st.columns([2, 3, 1])
with col1:
st.markdown(f"**{product['step']}**")
with col2:
st.markdown(product['product'])
with col3:
st.markdown(product['price'])
# Evening routine
st.markdown("### 🌙 Evening Routine")
evening_products = [
{"step": "1. Cleanser", "product": "CeraVe Hydrating Facial Cleanser", "price": "$12.99"},
{"step": "2. Treatment", "product": "The Ordinary Retinol 0.2% in Squalane", "price": "$9.90"},
{"step": "3. Moisturizer", "product": "CeraVe PM Facial Moisturizing Lotion", "price": "$16.99"}
]
for product in evening_products:
col1, col2, col3 = st.columns([2, 3, 1])
with col1:
st.markdown(f"**{product['step']}**")
with col2:
st.markdown(product['product'])
with col3:
st.markdown(product['price'])
# Weekly treatments
st.markdown("### 📅 Weekly Treatments")
st.markdown("- **2x per week**: The Ordinary AHA 30% + BHA 2% Peeling Solution")
st.markdown("- **1x per week**: Hydrating sheet mask")
total_cost = 139.66
st.markdown(f"### 💰 Total Monthly Cost: ${total_cost:.2f}")
with tab3:
st.subheader("Medical Insights & Recommendations")
# Medical alerts
st.markdown("### ⚠️ Medical Alerts")
alerts = []
if st.session_state.user_data.get('symptoms', {}).get('allergic_reactions'):
alerts.append("🚨 **Allergic reactions reported** - Patch test all new products before use")
if st.session_state.user_data.get('symptoms', {}).get('stinging'):
alerts.append("⚠️ **Stinging/burning sensations** - Avoid products with high acid concentrations")
if 'Redness' in st.session_state.user_data.get('skin_concerns', []):
alerts.append("🩺 **Persistent redness** - See dermatologist if redness lasts >2 weeks")
if st.session_state.user_data.get('age', 0) > 50:
alerts.append("📋 **Age consideration** - Annual skin cancer screening recommended")
if not alerts:
alerts.append("✅ **No immediate medical concerns** - Continue monitoring skin health")
for alert in alerts:
st.markdown(alert)
# General recommendations
st.markdown("### 📋 General Health Recommendations")
recommendations = [
"🔹 Perform monthly self-skin examinations",
"🔹 Use broad-spectrum SPF 30+ daily",
"🔹 Maintain adequate hydration (8+ glasses water daily)",
"🔹 Get 7-9 hours of quality sleep",
"🔹 Manage stress through exercise or meditation",
"🔹 Eat a balanced diet rich in antioxidants"
]
for rec in recommendations:
st.markdown(rec)
# When to see a dermatologist
st.markdown("### 🩺 When to Consult a Dermatologist")
st.markdown("- New or changing moles")
st.markdown("- Persistent acne not responding to treatment")
st.markdown("- Severe skin reactions or allergies")
st.markdown("- Skin concerns affecting quality of life")
# Action buttons
st.markdown("---")
col1, col2, col3 = st.columns(3)
with col1:
if st.button("📧 Email Report"):
st.success("Report sent to your email!")
with col2:
if st.button("📱 Save to Phone"):
st.success("Report saved to downloads!")
with col3:
if st.button("🔄 Start New Analysis", on_click=reset_form):
st.rerun()
# Footer
st.markdown("---")
st.markdown("*SkinGenius AI - Your personalized skincare companion*")
st.markdown("⚠️ This tool provides general guidance only. Always consult healthcare professionals for medical concerns.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?