Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,14 @@
|
|
| 1 |
import os
|
| 2 |
-
from pyngrok import ngrok
|
| 3 |
-
|
| 4 |
-
# Set your Groq API key here
|
| 5 |
-
os.environ["GROQ_API_KEY"] = "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" # Replace with your actual key
|
| 6 |
-
|
| 7 |
-
# Save app.py code
|
| 8 |
-
with open("app.py", "w") as f:
|
| 9 |
-
f.write("""
|
| 10 |
-
import os
|
| 11 |
import streamlit as st
|
| 12 |
from groq import Groq
|
| 13 |
from PIL import Image
|
| 14 |
-
import requests
|
| 15 |
-
from bs4 import BeautifulSoup
|
| 16 |
-
from selenium import webdriver
|
| 17 |
-
from selenium.webdriver.chrome.options import Options
|
| 18 |
-
from webdriver_manager.chrome import ChromeDriverManager
|
| 19 |
|
| 20 |
st.set_page_config(page_title="AI Fashion Stylist", layout="centered")
|
| 21 |
st.title("π AI Fashion Stylist")
|
| 22 |
st.markdown("Get fashion advice based on your outfit, event, and trends! Upload a photo if you like.")
|
| 23 |
|
| 24 |
-
# π Groq API Key
|
| 25 |
-
GROQ_API_KEY =
|
| 26 |
client = Groq(api_key=GROQ_API_KEY)
|
| 27 |
|
| 28 |
# π€ Upload dress photo (optional)
|
|
@@ -61,42 +47,3 @@ if st.button("β¨ Get My Fashion Advice"):
|
|
| 61 |
st.caption("π§ Powered by LLaMA 3 (Groq API)")
|
| 62 |
except Exception as e:
|
| 63 |
st.error(f"β Error: {e}")
|
| 64 |
-
|
| 65 |
-
# πΌ Sample Outfit Looks
|
| 66 |
-
st.subheader("πΌ Outfit Inspirations")
|
| 67 |
-
sample_looks = [
|
| 68 |
-
"https://cdn.pixabay.com/photo/2017/08/07/00/53/fashion-2596840_1280.jpg",
|
| 69 |
-
"https://cdn.pixabay.com/photo/2016/11/29/06/15/adult-1869116_1280.jpg",
|
| 70 |
-
"https://cdn.pixabay.com/photo/2017/08/06/00/03/fashion-2589430_1280.jpg"
|
| 71 |
-
]
|
| 72 |
-
cols = st.columns(3)
|
| 73 |
-
for i, img_url in enumerate(sample_looks):
|
| 74 |
-
with cols[i]:
|
| 75 |
-
st.image(img_url, use_container_width=True)
|
| 76 |
-
|
| 77 |
-
# π° Latest 2025 Fashion Trends
|
| 78 |
-
st.subheader("π° Latest 2025 Fashion Trends")
|
| 79 |
-
|
| 80 |
-
def fetch_trends(url, selector, site_name):
|
| 81 |
-
try:
|
| 82 |
-
response = requests.get(url, headers={"User-Agent": "Mozilla/5.0"})
|
| 83 |
-
soup = BeautifulSoup(response.content, "html.parser")
|
| 84 |
-
items = soup.select(selector)
|
| 85 |
-
st.markdown(f"**From {site_name}:**")
|
| 86 |
-
|
| 87 |
-
if not items:
|
| 88 |
-
st.info("No trend items found. The site structure may have changed.")
|
| 89 |
-
|
| 90 |
-
for item in items[:5]:
|
| 91 |
-
title = item.get_text(strip=True)
|
| 92 |
-
link = item.get("href", "#")
|
| 93 |
-
if not link.startswith("http"):
|
| 94 |
-
link = url.rstrip("/") + link
|
| 95 |
-
st.markdown(f"- [{title}]({link})")
|
| 96 |
-
except Exception as e:
|
| 97 |
-
st.warning(f"Could not fetch from {site_name}: {e}")
|
| 98 |
-
|
| 99 |
-
fetch_trends("https://www.vogue.com/fashion", "a.card-hed", "Vogue")
|
| 100 |
-
fetch_trends("https://www.elle.com/fashion/trend-reports/", "a.full-item-title", "Elle")
|
| 101 |
-
""")
|
| 102 |
-
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from groq import Groq
|
| 4 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
st.set_page_config(page_title="AI Fashion Stylist", layout="centered")
|
| 7 |
st.title("π AI Fashion Stylist")
|
| 8 |
st.markdown("Get fashion advice based on your outfit, event, and trends! Upload a photo if you like.")
|
| 9 |
|
| 10 |
+
# π Groq API Key from Hugging Face secrets
|
| 11 |
+
GROQ_API_KEY = st.secrets["GROQ_API_KEY"]
|
| 12 |
client = Groq(api_key=GROQ_API_KEY)
|
| 13 |
|
| 14 |
# π€ Upload dress photo (optional)
|
|
|
|
| 47 |
st.caption("π§ Powered by LLaMA 3 (Groq API)")
|
| 48 |
except Exception as e:
|
| 49 |
st.error(f"β Error: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|