Compare commits
No commits in common. 'main' and 'dev' have entirely different histories.
@ -1,2 +0,0 @@
|
|||||||
OPENAI_API_KEY=MOONSHOT_API_KEY
|
|
||||||
WEATHER_API_KEY=639ab98ac7710557eb8d9155d9a25e80
|
|
@ -1,8 +0,0 @@
|
|||||||
# 默认忽略的文件
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="PYTHON_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="Python 3.12 (PycharmProjects)" jdkType="Python SDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<settings>
|
|
||||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
|
||||||
<version value="1.0" />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Black">
|
|
||||||
<option name="sdkName" value="Python 3.12 (PycharmProjects)" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/PycharmProjects.iml" filepath="$PROJECT_DIR$/.idea/PycharmProjects.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,32 +0,0 @@
|
|||||||
import streamlit as st
|
|
||||||
from templates.user_info import show_user_info_form
|
|
||||||
from templates.recommendations import show_recommendations_tab
|
|
||||||
from templates.recommendations import show_virtual_tryon_tab
|
|
||||||
|
|
||||||
|
|
||||||
# 页面设置
|
|
||||||
st.set_page_config(page_title="智能穿搭助手", page_icon="👗", layout="wide")
|
|
||||||
|
|
||||||
# 标题和介绍
|
|
||||||
st.title("👗 智能穿搭助手")
|
|
||||||
|
|
||||||
# 初始化session state
|
|
||||||
if 'user_info' not in st.session_state:
|
|
||||||
st.session_state.user_info = {}
|
|
||||||
if 'recommendations' not in st.session_state:
|
|
||||||
st.session_state.recommendations = None
|
|
||||||
|
|
||||||
# 侧边栏 - 用户信息收集
|
|
||||||
show_user_info_form()
|
|
||||||
|
|
||||||
# 主界面
|
|
||||||
tab1, tab2 = st.tabs(["穿搭推荐", "虚拟试衣"])
|
|
||||||
|
|
||||||
with tab1:
|
|
||||||
show_recommendations_tab()
|
|
||||||
|
|
||||||
with tab2:
|
|
||||||
show_virtual_tryon_tab()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
st.write("")
|
|
@ -1,17 +0,0 @@
|
|||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 中国主要城市中英文对照表
|
|
||||||
CITY_NAME_MAPPING = {
|
|
||||||
# 直辖市
|
|
||||||
"beijing": "北京", "peking": "北京",
|
|
||||||
"shanghai": "上海",
|
|
||||||
# ... (保持原有的城市映射不变)
|
|
||||||
}
|
|
||||||
|
|
||||||
# 加载环境变量
|
|
||||||
load_dotenv()
|
|
||||||
MOONSHOT_API_KEY = os.getenv("MOONSHOT_API_KEY")
|
|
||||||
WEATHER_API_KEY = os.getenv("WEATHER_API_KEY")
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,25 +0,0 @@
|
|||||||
import streamlit as st
|
|
||||||
|
|
||||||
|
|
||||||
def show_user_info_form():
|
|
||||||
with st.sidebar:
|
|
||||||
st.header("个人信息")
|
|
||||||
with st.form("user_info_form"):
|
|
||||||
gender = st.selectbox("性别", ["女", "男", "其他"])
|
|
||||||
age = st.slider("年龄", 10, 80, 25)
|
|
||||||
height = st.number_input("身高(cm)", 100, 250, 165)
|
|
||||||
weight = st.number_input("体重(kg)", 30, 150, 55)
|
|
||||||
skin_tone = st.selectbox("肤色", ["白皙", "自然", "小麦色", "深色"])
|
|
||||||
style_preference = st.multiselect("风格偏好", ["休闲", "正式", "运动", "甜美", "复古", "街头", "商务"])
|
|
||||||
submitted = st.form_submit_button("保存信息")
|
|
||||||
|
|
||||||
if submitted:
|
|
||||||
st.session_state.user_info = {
|
|
||||||
"gender": gender,
|
|
||||||
"age": age,
|
|
||||||
"height": height,
|
|
||||||
"weight": weight,
|
|
||||||
"skin_tone": skin_tone,
|
|
||||||
"style_preference": style_preference
|
|
||||||
}
|
|
||||||
st.success("个人信息已保存!")
|
|
@ -1,3 +0,0 @@
|
|||||||
from .weather import get_weather_data
|
|
||||||
from .outfits import generate_sample_outfits
|
|
||||||
from .image_processing import process_image_for_try_on
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,11 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
|
|
||||||
def process_image_for_try_on(image):
|
|
||||||
"""处理上传的试衣图片"""
|
|
||||||
img_array = np.array(image)
|
|
||||||
gray = cv2.cvtColor(img_array, cv2.COLOR_BGR2GRAY)
|
|
||||||
edges = cv2.Canny(gray, 100, 200)
|
|
||||||
return gray, edges
|
|
@ -1,35 +0,0 @@
|
|||||||
import requests
|
|
||||||
from config import CITY_NAME_MAPPING, WEATHER_API_KEY
|
|
||||||
|
|
||||||
|
|
||||||
def get_weather_data(city, api_key=WEATHER_API_KEY):
|
|
||||||
"""获取天气数据"""
|
|
||||||
base_url = "http://api.openweathermap.org/data/2.5/weather"
|
|
||||||
params = {
|
|
||||||
"q": city,
|
|
||||||
"appid": api_key,
|
|
||||||
"units": "metric",
|
|
||||||
"lang": "zh_cn"
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = requests.get(base_url, params=params, timeout=10)
|
|
||||||
data = response.json()
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
normalized_input = city.lower().replace(" ", "")
|
|
||||||
chinese_name = CITY_NAME_MAPPING.get(normalized_input, data.get("name", city))
|
|
||||||
|
|
||||||
return {
|
|
||||||
"city": chinese_name,
|
|
||||||
"temp": data["main"]["temp"],
|
|
||||||
"humidity": data["main"]["humidity"],
|
|
||||||
"description": data["weather"][0]["description"],
|
|
||||||
"icon": data["weather"][0]["icon"]
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取天气数据时出错: {str(e)}")
|
|
||||||
return None
|
|
Loading…
Reference in new issue