Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,137 +1,59 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import os, random
|
| 3 |
-
from groq import Groq
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
stickers = [
|
| 10 |
-
"https://media.giphy.com/media/3o6Zt481isNVuQI1l6/giphy.gif", # Cream applying
|
| 11 |
-
"https://media.giphy.com/media/l3q2XB76CaWPggiNW/giphy.gif", # Aloe vera
|
| 12 |
-
"https://media.giphy.com/media/26tPplGWjN0xLybiU/giphy.gif", # Water drinking
|
| 13 |
-
"https://media.giphy.com/media/3o7TKP9XDb9IzUrJXa/giphy.gif", # Cucumber eyes
|
| 14 |
-
"https://media.giphy.com/media/26Fxy3Iz1ari8oytO/giphy.gif", # Face mask cute
|
| 15 |
-
]
|
| 16 |
-
|
| 17 |
-
def skincare_advice(name, gender, age, skin_concern, description, image, duration, sensitivity, routine):
|
| 18 |
-
if not description.strip() and (skin_concern == "Other" or not skin_concern.strip()):
|
| 19 |
-
return "β Please select or describe your skin concern."
|
| 20 |
-
if not name.strip():
|
| 21 |
-
return "β Please enter your name for personalized advice."
|
| 22 |
-
|
| 23 |
-
user_issue = description if description.strip() else skin_concern
|
| 24 |
-
random_factor = random.randint(1, 10000)
|
| 25 |
-
|
| 26 |
-
if gender == "Female":
|
| 27 |
-
gender_pref = "Focus on hydration, mild natural ingredients, and avoid harsh scrubs."
|
| 28 |
-
elif gender == "Male":
|
| 29 |
-
gender_pref = "Men often need oil-control and deep cleansing due to thicker skin."
|
| 30 |
-
else:
|
| 31 |
-
gender_pref = "Use a balanced routine suitable for all skin types."
|
| 32 |
-
|
| 33 |
-
prompt = f"""
|
| 34 |
-
User Profile:
|
| 35 |
-
- Name: {name}
|
| 36 |
-
- Gender: {gender}
|
| 37 |
-
- Age: {age}
|
| 38 |
-
- Skin Concern: {skin_concern}
|
| 39 |
-
- Description: {user_issue}
|
| 40 |
-
- Duration: {duration}
|
| 41 |
-
- Sensitive Skin: {sensitivity}
|
| 42 |
-
- Skincare Routine: {routine}
|
| 43 |
-
|
| 44 |
-
Additional Preference based on Gender:
|
| 45 |
-
{gender_pref}
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
π§΄ Daily Care Routine (3 bullet points)
|
| 54 |
-
πΏ One Natural Remedy (unique each time)
|
| 55 |
-
π‘ 3 Lifestyle Tips (not generic, vary)
|
| 56 |
-
π¬ Motivational Quote (1 line, italic)
|
| 57 |
-
"""
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
except:
|
| 66 |
-
result = f"""
|
| 67 |
-
π Hi {name}, great to see you here!
|
| 68 |
-
π©Ί Your skin concern: {skin_concern}
|
| 69 |
-
π Around {random.randint(10,80)}% of people face this issue globally.
|
| 70 |
-
π§΄ Daily Care Routine:
|
| 71 |
-
β’ Cleanse twice daily with a mild face wash
|
| 72 |
-
β’ Hydrate with light moisturizer
|
| 73 |
-
β’ Apply SPF 30 sunscreen before going out
|
| 74 |
-
πΏ Natural Remedy: Honey + turmeric paste for 10 mins once a week
|
| 75 |
-
π‘ Lifestyle Tips:
|
| 76 |
-
β’ Sleep at least 7 hrs daily
|
| 77 |
-
β’ Eat omega-rich foods (fish, nuts)
|
| 78 |
-
β’ Avoid touching your face frequently
|
| 79 |
-
π¬ *Your skin reflects how kindly you treat yourself.*
|
| 80 |
-
"""
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
("π‘", "Lifestyle Tips"),
|
| 92 |
-
("π¬", "Quote")
|
| 93 |
-
]:
|
| 94 |
-
formatted_output = formatted_output.replace(
|
| 95 |
-
emoji,
|
| 96 |
-
f"<h4 style='color:red;'>{emoji} {title}</h4><div style='color:black;'>"
|
| 97 |
-
)
|
| 98 |
-
formatted_output += "</div>"
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
border-radius:15px; border:2px solid #000; box-shadow:0px 3px 10px rgba(0,0,0,0.3);'>
|
| 103 |
-
<div style='display:flex; align-items:center; justify-content:space-between;'>
|
| 104 |
-
<h2 style='color:#000; margin:0;'>π€ <b>{name}</b> | {gender}, {age} yrs</h2>
|
| 105 |
-
<img src="{sticker}" style="width:70px; border-radius:10px;">
|
| 106 |
-
</div>
|
| 107 |
-
<div style='margin-top:15px; font-size:16px; line-height:1.7;'>
|
| 108 |
-
{formatted_output.replace('*', '<b>').replace('', '</b>')}
|
| 109 |
-
</div>
|
| 110 |
</div>
|
|
|
|
|
|
|
|
|
|
| 111 |
"""
|
| 112 |
|
| 113 |
-
#
|
| 114 |
st.set_page_config(page_title="SkinSense AI", layout="centered")
|
| 115 |
-
st.markdown("""
|
| 116 |
-
<h1 style='text-align:center; font-family:Arial; font-size:30px;
|
| 117 |
-
background: linear-gradient(to right, black, #4CAF50);
|
| 118 |
-
-webkit-background-clip: text; color: transparent;'>
|
| 119 |
-
πΏ <b>Welcome to SkinSense AI β Your Smart Skincare Buddy</b>
|
| 120 |
-
</h1>
|
| 121 |
-
""", unsafe_allow_html=True)
|
| 122 |
|
| 123 |
-
|
| 124 |
-
name = st.text_input("π Name")
|
| 125 |
-
gender = st.selectbox("π» Gender", ["Female", "Male", "Other"])
|
| 126 |
-
age = st.slider("π Age", 5, 100, 25)
|
| 127 |
-
skin_concern = st.selectbox("π Select a Common Skin Concern", ["Dark Spots", "Acne", "Tanned Skin", "Oily Skin", "Dryness", "Other"])
|
| 128 |
-
description = st.text_area("π§Ύ Or Describe Your Skin Concern")
|
| 129 |
-
image = st.file_uploader("π· Upload Image (optional)")
|
| 130 |
-
duration = st.selectbox("β³ How long?", ["π Less than a week", "π 1β4 weeks", "π
Over a month"])
|
| 131 |
-
sensitivity = st.selectbox("π§ͺ Sensitive Skin?", ["Yes", "No", "Not Sure"])
|
| 132 |
-
routine = st.selectbox("π§΄ Skincare Routine?", ["Yes", "No"])
|
| 133 |
-
submit = st.form_submit_button("β¨ Get My Personalized Advice")
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
def generate_response(name, concern):
|
| 4 |
+
return f"""
|
| 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: {concern} have appeared on your skin, affecting your confidence. It's essential to address this concern to even out your skin tone.
|
| 11 |
+
</div>
|
| 12 |
|
| 13 |
+
<h4 style='color:red;'>π Global Insight</h4>
|
| 14 |
+
<div style='color:black;'>
|
| 15 |
+
Global Insight: Did you know that 74% of women experience skin issues during their 20s? It's common to have skin concerns at this age, and with proper care, you can overcome them.
|
| 16 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
<h4 style='color:red;'>π§΄ Daily Care Routine</h4>
|
| 19 |
+
<div style='color:black;'>
|
| 20 |
+
β’ Use a mild cleanser suitable for sensitive skin to avoid stripping your skin of its natural oils.<br>
|
| 21 |
+
β’ Apply a hyaluronic acid serum to lock in moisture and soothe your skin.<br>
|
| 22 |
+
β’ Finish your routine with a lightweight, non-comedogenic moisturizer to provide long-lasting hydration.
|
| 23 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
<h4 style='color:red;'>πΏ Natural Remedy</h4>
|
| 26 |
+
<div style='color:black;'>
|
| 27 |
+
One Natural Remedy: Try using aloe vera gel on your dark spots. Aloe vera has anti-inflammatory properties that can help reduce the appearance of dark spots and hyperpigmentation.
|
| 28 |
+
</div>
|
| 29 |
|
| 30 |
+
<h4 style='color:red;'>π‘ Lifestyle Tips</h4>
|
| 31 |
+
<div style='color:black;'>
|
| 32 |
+
3 Lifestyle Tips:<br>
|
| 33 |
+
β’ Get at least 7β8 hours of sleep to help your skin regenerate and repair itself.<br>
|
| 34 |
+
β’ Drink plenty of water throughout the day to keep your skin hydrated from the inside out.<br>
|
| 35 |
+
β’ Avoid picking or squeezing your skin, as this can cause further darkening of the spots and lead to scarring.
|
| 36 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
<div style='color:black; font-weight:bold; margin-top:10px;'>
|
| 39 |
+
_Your skin is a canvas, paint it with kindness and care._
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
</div>
|
| 41 |
+
|
| 42 |
+
<h4 style='color:red;'>π¬ Quote</h4>
|
| 43 |
+
<div style='color:black;'>βDo something today that your future self will thank you for.β</div>
|
| 44 |
"""
|
| 45 |
|
| 46 |
+
# Streamlit UI
|
| 47 |
st.set_page_config(page_title="SkinSense AI", layout="centered")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
st.title("π§΄ SkinSense AI - Personalized Skincare Assistant")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
with st.form("skincare_form"):
|
| 52 |
+
name = st.text_input("Your Name", placeholder="e.g., Javeria")
|
| 53 |
+
concern = st.text_area("Describe Your Skin Concern", placeholder="e.g., I have dark spots on my cheeks")
|
| 54 |
+
submit = st.form_submit_button("Get My Skincare Plan")
|
| 55 |
+
|
| 56 |
+
if submit and name and concern:
|
| 57 |
+
st.markdown("---")
|
| 58 |
+
st.subheader("π§Ύ Your Personalized Skin Guide")
|
| 59 |
+
st.markdown(generate_response(name, concern), unsafe_allow_html=True)
|