Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,34 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
<h4 style='color:red;'>π Greeting</h4>
|
| 6 |
<div style='color:black;'>Hey {name}! π</div>
|
| 7 |
|
| 8 |
<h4 style='color:red;'>π©Ί Skin Issue Summary</h4>
|
| 9 |
<div style='color:black;'>
|
| 10 |
-
Skin Issue Summary:
|
| 11 |
</div>
|
| 12 |
|
| 13 |
<h4 style='color:red;'>π Global Insight</h4>
|
|
@@ -43,17 +64,42 @@ def generate_response(name, concern):
|
|
| 43 |
<div style='color:black;'>βDo something today that your future self will thank you for.β</div>
|
| 44 |
"""
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
st.set_page_config(page_title="SkinSense AI", layout="centered")
|
| 48 |
|
| 49 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
with st.form("skincare_form"):
|
| 52 |
-
name = st.text_input("
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
st.
|
| 58 |
-
st.
|
| 59 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import os, random
|
| 3 |
+
from groq import Groq
|
| 4 |
|
| 5 |
+
# β
Initialize Groq client
|
| 6 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 7 |
+
|
| 8 |
+
# β
Cute skincare stickers
|
| 9 |
+
stickers = [
|
| 10 |
+
"https://media.giphy.com/media/3o6Zt481isNVuQI1l6/giphy.gif",
|
| 11 |
+
"https://media.giphy.com/media/l3q2XB76CaWPggiNW/giphy.gif",
|
| 12 |
+
"https://media.giphy.com/media/26tPplGWjN0xLybiU/giphy.gif",
|
| 13 |
+
"https://media.giphy.com/media/3o7TKP9XDb9IzUrJXa/giphy.gif",
|
| 14 |
+
"https://media.giphy.com/media/26Fxy3Iz1ari8oytO/giphy.gif",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
# β
Hardcoded formatted output for demo
|
| 18 |
+
def skincare_advice(name, gender, age, skin_concern, description, image, duration, sensitivity, routine):
|
| 19 |
+
if not name.strip():
|
| 20 |
+
return "β Please enter your name."
|
| 21 |
+
|
| 22 |
+
sticker = random.choice(stickers)
|
| 23 |
+
|
| 24 |
+
# β
Replace 'Javeria' with actual name in template
|
| 25 |
+
formatted_output = f"""
|
| 26 |
<h4 style='color:red;'>π Greeting</h4>
|
| 27 |
<div style='color:black;'>Hey {name}! π</div>
|
| 28 |
|
| 29 |
<h4 style='color:red;'>π©Ί Skin Issue Summary</h4>
|
| 30 |
<div style='color:black;'>
|
| 31 |
+
Skin Issue Summary: Dark spots have appeared on your skin, affecting your confidence. It's essential to address this concern to even out your skin tone.
|
| 32 |
</div>
|
| 33 |
|
| 34 |
<h4 style='color:red;'>π Global Insight</h4>
|
|
|
|
| 64 |
<div style='color:black;'>βDo something today that your future self will thank you for.β</div>
|
| 65 |
"""
|
| 66 |
|
| 67 |
+
return f"""
|
| 68 |
+
<div style='font-family:Arial, sans-serif; color:#111; background:#fff; padding:20px;
|
| 69 |
+
border-radius:15px; border:2px solid #000; box-shadow:0px 3px 10px rgba(0,0,0,0.3);'>
|
| 70 |
+
<div style='display:flex; align-items:center; justify-content:space-between;'>
|
| 71 |
+
<h2 style='color:#000; margin:0;'>π€ <b>{name}</b> | {gender}, {age} yrs</h2>
|
| 72 |
+
<img src="{sticker}" style="width:70px; border-radius:10px;">
|
| 73 |
+
</div>
|
| 74 |
+
<div style='margin-top:15px; font-size:16px; line-height:1.7;'>
|
| 75 |
+
{formatted_output}
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
# β
Streamlit UI
|
| 81 |
st.set_page_config(page_title="SkinSense AI", layout="centered")
|
| 82 |
|
| 83 |
+
st.markdown("""
|
| 84 |
+
<h1 style='text-align:center; font-family:Arial; font-size:30px;
|
| 85 |
+
background: linear-gradient(to right, black, #4CAF50);
|
| 86 |
+
-webkit-background-clip: text; color: transparent;'>
|
| 87 |
+
πΏ <b>Welcome to SkinSense AI β Your Smart Skincare Buddy</b>
|
| 88 |
+
</h1>
|
| 89 |
+
""", unsafe_allow_html=True)
|
| 90 |
|
| 91 |
with st.form("skincare_form"):
|
| 92 |
+
name = st.text_input("π Name")
|
| 93 |
+
gender = st.selectbox("π» Gender", ["Female", "Male", "Other"])
|
| 94 |
+
age = st.slider("π Age", 5, 100, 25)
|
| 95 |
+
skin_concern = st.selectbox("π Select a Common Skin Concern", ["Dark Spots", "Acne", "Tanned Skin", "Oily Skin", "Dryness", "Other"])
|
| 96 |
+
description = st.text_area("π§Ύ Or Describe Your Skin Concern")
|
| 97 |
+
image = st.file_uploader("π· Upload Image (optional)")
|
| 98 |
+
duration = st.selectbox("β³ How long?", ["π Less than a week", "π 1β4 weeks", "π
Over a month"])
|
| 99 |
+
sensitivity = st.selectbox("π§ͺ Sensitive Skin?", ["Yes", "No", "Not Sure"])
|
| 100 |
+
routine = st.selectbox("π§΄ Skincare Routine?", ["Yes", "No"])
|
| 101 |
+
submit = st.form_submit_button("β¨ Get My Personalized Advice")
|
| 102 |
+
|
| 103 |
+
if submit:
|
| 104 |
+
output = skincare_advice(name, gender, age, skin_concern, description, image, duration, sensitivity, routine)
|
| 105 |
+
st.markdown(output, unsafe_allow_html=True)
|