Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,50 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def analyze_concepts(month):
|
5 |
"""고도화된 월별 컨셉 분석"""
|
6 |
|
7 |
-
# 월별 상세 데이터
|
8 |
monthly_data = {
|
9 |
"1월": {
|
10 |
"holidays": ["신정", "설날", "대보름"],
|
11 |
"special_days": ["새해 첫날", "성인의 날", "다이어트의 달"],
|
|
|
12 |
"trends": ["새해 다짐", "다이어트", "정리정돈", "미니멀라이프", "헬스케어"],
|
13 |
"seasons": ["겨울", "신년", "눈꽃"],
|
14 |
"colors": ["#FF6B6B", "#4ECDC4", "#45B7D1"],
|
@@ -17,6 +53,7 @@ def analyze_concepts(month):
|
|
17 |
"2월": {
|
18 |
"holidays": ["밸런타인데이", "정월대보름"],
|
19 |
"special_days": ["로즈데이", "초콜릿데이", "사랑의 달"],
|
|
|
20 |
"trends": ["사랑", "로맨스", "셀프케어", "따뜻한 감성", "커플문화"],
|
21 |
"seasons": ["겨울 끝", "입춘", "매화"],
|
22 |
"colors": ["#FF69B4", "#FFB6C1", "#DC143C"],
|
@@ -25,6 +62,7 @@ def analyze_concepts(month):
|
|
25 |
"3월": {
|
26 |
"holidays": ["삼일절", "화이트데이"],
|
27 |
"special_days": ["여성의 날", "봄의 시작", "졸업식"],
|
|
|
28 |
"trends": ["봄맞이", "새학기", "벚꽃놀이", "봄나들이", "새출발"],
|
29 |
"seasons": ["봄", "벚꽃", "새싹"],
|
30 |
"colors": ["#FFB6C1", "#98FB98", "#87CEEB"],
|
@@ -33,6 +71,7 @@ def analyze_concepts(month):
|
|
33 |
"4월": {
|
34 |
"holidays": ["만우절", "식목일"],
|
35 |
"special_days": ["블랙데이", "킹데이", "꽃구경"],
|
|
|
36 |
"trends": ["벚꽃축제", "봄피크닉", "아웃도어", "꽃놀이", "드라이브"],
|
37 |
"seasons": ["봄 절정", "꽃구경", "나들이"],
|
38 |
"colors": ["#98FB98", "#F0E68C", "#DDA0DD"],
|
@@ -41,6 +80,7 @@ def analyze_concepts(month):
|
|
41 |
"5월": {
|
42 |
"holidays": ["어린이날", "어버이날", "스승의날", "부처님오신날"],
|
43 |
"special_days": ["가정의 달", "로즈데이", "감사의 달"],
|
|
|
44 |
"trends": ["가족사랑", "감사", "나들이", "선물", "효도여행"],
|
45 |
"seasons": ["신록", "야외활동", "따뜻함"],
|
46 |
"colors": ["#32CD32", "#FFB6C1", "#87CEEB"],
|
@@ -49,30 +89,34 @@ def analyze_concepts(month):
|
|
49 |
"6월": {
|
50 |
"holidays": ["현충일", "단오"],
|
51 |
"special_days": ["키스데이", "패밀리데이", "환경의 날"],
|
|
|
52 |
"trends": ["여름준비", "다이어트", "워터파크", "바캉스준비", "쿨링"],
|
53 |
"seasons": ["초여름", "장마 전", "더위"],
|
54 |
"colors": ["#00CED1", "#FFD700", "#FF6347"],
|
55 |
"mood": "시원하고 활동적인"
|
56 |
},
|
57 |
"7월": {
|
58 |
-
"holidays": ["제헌절"
|
59 |
"special_days": ["실버데이", "썸머데이", "휴가철"],
|
|
|
60 |
"trends": ["여름휴가", "워터액티비티", "시원한음식", "휴가패션", "바다여행"],
|
61 |
"seasons": ["여름", "장마", "휴가"],
|
62 |
"colors": ["#00BFFF", "#FFD700", "#FF6347"],
|
63 |
"mood": "역동적이고 시원한"
|
64 |
},
|
65 |
"8월": {
|
66 |
-
"holidays": ["
|
67 |
"special_days": ["그린데이", "바캉스", "여름 끝"],
|
|
|
68 |
"trends": ["여름휴가절정", "바다여행", "축제", "여름추억", "해외여행"],
|
69 |
"seasons": ["한여름", "무더위", "휴가철"],
|
70 |
"colors": ["#00BFFF", "#FF6347", "#FFD700"],
|
71 |
"mood": "열정적이고 추억가득한"
|
72 |
},
|
73 |
"9월": {
|
74 |
-
"holidays": ["추석"
|
75 |
"special_days": ["포토데이", "뮤직데이", "한가위"],
|
|
|
76 |
"trends": ["추석준비", "가을패션", "독서", "문화생활", "전통"],
|
77 |
"seasons": ["가을", "추석", "선선함"],
|
78 |
"colors": ["#FF8C00", "#DC143C", "#B8860B"],
|
@@ -81,6 +125,7 @@ def analyze_concepts(month):
|
|
81 |
"10월": {
|
82 |
"holidays": ["개천절", "한글날"],
|
83 |
"special_days": ["와인데이", "커피데이", "독서의 달"],
|
|
|
84 |
"trends": ["가을단풍", "독서", "카페문화", "가을나들이", "문화예술"],
|
85 |
"seasons": ["단풍", "가을정취", "쌀쌀함"],
|
86 |
"colors": ["#FF8C00", "#DC143C", "#B8860B"],
|
@@ -89,6 +134,7 @@ def analyze_concepts(month):
|
|
89 |
"11월": {
|
90 |
"holidays": ["빼빼로데이", "수능"],
|
91 |
"special_days": ["무비데이", "오렌지데이", "김장철"],
|
|
|
92 |
"trends": ["빼빼로데이", "수능응원", "겨울준비", "연말준비", "감사"],
|
93 |
"seasons": ["늦가을", "쌀쌀함", "겨울준비"],
|
94 |
"colors": ["#8B4513", "#A0522D", "#CD853F"],
|
@@ -97,6 +143,7 @@ def analyze_concepts(month):
|
|
97 |
"12월": {
|
98 |
"holidays": ["크리스마스", "성탄절", "동지"],
|
99 |
"special_days": ["허그데이", "키스데이", "연말"],
|
|
|
100 |
"trends": ["크리스마스", "연말파티", "선물", "한해마무리", "송년회"],
|
101 |
"seasons": ["겨울", "연말", "눈"],
|
102 |
"colors": ["#DC143C", "#228B22", "#FFD700"],
|
@@ -106,7 +153,7 @@ def analyze_concepts(month):
|
|
106 |
|
107 |
data = monthly_data.get(month, {})
|
108 |
|
109 |
-
#
|
110 |
concepts = []
|
111 |
|
112 |
# 컨셉 1: 주요 기념일 기반
|
@@ -123,7 +170,21 @@ def analyze_concepts(month):
|
|
123 |
"participation_factor": "기념일 특별감, 시즌성"
|
124 |
})
|
125 |
|
126 |
-
# 컨셉 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
if data.get("trends"):
|
128 |
main_trend = data["trends"][0]
|
129 |
concepts.append({
|
@@ -137,7 +198,7 @@ def analyze_concepts(month):
|
|
137 |
"participation_factor": "트렌드 화제성, SNS 확산성"
|
138 |
})
|
139 |
|
140 |
-
# 컨셉
|
141 |
if data.get("seasons"):
|
142 |
season = data["seasons"][0]
|
143 |
concepts.append({
|
@@ -151,7 +212,7 @@ def analyze_concepts(month):
|
|
151 |
"participation_factor": "계절 공감대, 일상 연관성"
|
152 |
})
|
153 |
|
154 |
-
# 컨셉
|
155 |
if data.get("special_days"):
|
156 |
special = data["special_days"][0]
|
157 |
concepts.append({
|
@@ -165,7 +226,7 @@ def analyze_concepts(month):
|
|
165 |
"participation_factor": "특별함 기대, 혜택 매력도"
|
166 |
})
|
167 |
|
168 |
-
# 컨셉
|
169 |
concepts.append({
|
170 |
"name": f"{month} 우리들의 이야기",
|
171 |
"theme": "커뮤니티 멤버 간 소통과 공감 이벤트",
|
@@ -178,10 +239,11 @@ def analyze_concepts(month):
|
|
178 |
})
|
179 |
|
180 |
# 결과 텍스트 생성
|
181 |
-
result = f"# 🎯 {month} 고도화된 컨셉
|
182 |
result += f"**📊 분석 기준:** {data.get('mood', '특별한')} 분위기\n"
|
183 |
result += f"**🎨 주요 색상:** {', '.join(data.get('colors', ['기본색상'])[:3])}\n"
|
184 |
-
result += f"**🔥 핵심 트렌드:** {', '.join(data.get('trends', ['기본트렌드'])[:3])}\n
|
|
|
185 |
|
186 |
concept_names = []
|
187 |
|
@@ -277,14 +339,15 @@ def create_interface():
|
|
277 |
|
278 |
event_period_input = gr.Textbox(
|
279 |
label="이벤트 기간",
|
280 |
-
placeholder="예: 2024.12.01 ~ 2024.12.07 (
|
281 |
-
info="
|
282 |
)
|
283 |
|
284 |
month_dropdown = gr.Dropdown(
|
285 |
choices=[f"{i}월" for i in range(1, 13)],
|
286 |
label="이벤트 월 선택",
|
287 |
-
value="1월"
|
|
|
288 |
)
|
289 |
|
290 |
analyze_btn = gr.Button("컨셉 분석하기", variant="primary")
|
|
|
1 |
+
def handle_period_change(period_text):
|
2 |
+
"""이벤트 기간 변경시 월 자동 인식"""
|
3 |
+
detected_month = extract_month_from_period(period_text)
|
4 |
+
if detected_month:
|
5 |
+
return gr.update(value=detected_month)
|
6 |
+
return gr.update()
|
7 |
+
|
8 |
+
def hanimport gradio as gr
|
9 |
from datetime import datetime
|
10 |
+
import re
|
11 |
+
|
12 |
+
def extract_month_from_period(period_text):
|
13 |
+
"""이벤트 기간에서 월 추출"""
|
14 |
+
if not period_text or period_text.strip() == "":
|
15 |
+
return None
|
16 |
+
|
17 |
+
# 날짜 패턴 찾기 (YYYY.MM.DD 또는 MM.DD 형식)
|
18 |
+
date_patterns = [
|
19 |
+
r'(\d{4})\.(\d{1,2})\.(\d{1,2})', # 2024.12.01
|
20 |
+
r'(\d{1,2})\.(\d{1,2})', # 12.01
|
21 |
+
r'(\d{1,2})월', # 12월
|
22 |
+
]
|
23 |
+
|
24 |
+
for pattern in date_patterns:
|
25 |
+
matches = re.findall(pattern, period_text)
|
26 |
+
if matches:
|
27 |
+
if len(matches[0]) == 3: # YYYY.MM.DD
|
28 |
+
month = int(matches[0][1])
|
29 |
+
elif len(matches[0]) == 2: # MM.DD
|
30 |
+
month = int(matches[0][0])
|
31 |
+
else: # 월
|
32 |
+
month = int(matches[0])
|
33 |
+
|
34 |
+
if 1 <= month <= 12:
|
35 |
+
return f"{month}월"
|
36 |
+
|
37 |
+
return None
|
38 |
|
39 |
def analyze_concepts(month):
|
40 |
"""고도화된 월별 컨셉 분석"""
|
41 |
|
42 |
+
# 월별 상세 데이터 (절기 포함)
|
43 |
monthly_data = {
|
44 |
"1월": {
|
45 |
"holidays": ["신정", "설날", "대보름"],
|
46 |
"special_days": ["새해 첫날", "성인의 날", "다이어트의 달"],
|
47 |
+
"seasonal_terms": ["소한", "대한", "입춘"], # 절기 추가
|
48 |
"trends": ["새해 다짐", "다이어트", "정리정돈", "미니멀라이프", "헬스케어"],
|
49 |
"seasons": ["겨울", "신년", "눈꽃"],
|
50 |
"colors": ["#FF6B6B", "#4ECDC4", "#45B7D1"],
|
|
|
53 |
"2월": {
|
54 |
"holidays": ["밸런타인데이", "정월대보름"],
|
55 |
"special_days": ["로즈데이", "초콜릿데이", "사랑의 달"],
|
56 |
+
"seasonal_terms": ["입춘", "우수"],
|
57 |
"trends": ["사랑", "로맨스", "셀프케어", "따뜻한 감성", "커플문화"],
|
58 |
"seasons": ["겨울 끝", "입춘", "매화"],
|
59 |
"colors": ["#FF69B4", "#FFB6C1", "#DC143C"],
|
|
|
62 |
"3월": {
|
63 |
"holidays": ["삼일절", "화이트데이"],
|
64 |
"special_days": ["여성의 날", "봄의 시작", "졸업식"],
|
65 |
+
"seasonal_terms": ["경칩", "춘분"],
|
66 |
"trends": ["봄맞이", "새학기", "벚꽃놀이", "봄나들이", "새출발"],
|
67 |
"seasons": ["봄", "벚꽃", "새싹"],
|
68 |
"colors": ["#FFB6C1", "#98FB98", "#87CEEB"],
|
|
|
71 |
"4월": {
|
72 |
"holidays": ["만우절", "식목일"],
|
73 |
"special_days": ["블랙데이", "킹데이", "꽃구경"],
|
74 |
+
"seasonal_terms": ["청명", "곡우"],
|
75 |
"trends": ["벚꽃축제", "봄피크닉", "아웃도어", "꽃놀이", "드라이브"],
|
76 |
"seasons": ["봄 절정", "꽃구경", "나들이"],
|
77 |
"colors": ["#98FB98", "#F0E68C", "#DDA0DD"],
|
|
|
80 |
"5월": {
|
81 |
"holidays": ["어린이날", "어버이날", "스승의날", "부처님오신날"],
|
82 |
"special_days": ["가정의 달", "로즈데이", "감사의 달"],
|
83 |
+
"seasonal_terms": ["입하", "소만"],
|
84 |
"trends": ["가족사랑", "감사", "나들이", "선물", "효도여행"],
|
85 |
"seasons": ["신록", "야외활동", "따뜻함"],
|
86 |
"colors": ["#32CD32", "#FFB6C1", "#87CEEB"],
|
|
|
89 |
"6월": {
|
90 |
"holidays": ["현충일", "단오"],
|
91 |
"special_days": ["키스데이", "패밀리데이", "환경의 날"],
|
92 |
+
"seasonal_terms": ["망종", "하지"],
|
93 |
"trends": ["여름준비", "다이어트", "워터파크", "바캉스준비", "쿨링"],
|
94 |
"seasons": ["초여름", "장마 전", "더위"],
|
95 |
"colors": ["#00CED1", "#FFD700", "#FF6347"],
|
96 |
"mood": "시원하고 활동적인"
|
97 |
},
|
98 |
"7월": {
|
99 |
+
"holidays": ["제헌절"],
|
100 |
"special_days": ["실버데이", "썸머데이", "휴가철"],
|
101 |
+
"seasonal_terms": ["소서", "대서", "초복", "중복"], # 복날 포함
|
102 |
"trends": ["여름휴가", "워터액티비티", "시원한음식", "휴가패션", "바다여행"],
|
103 |
"seasons": ["여름", "장마", "휴가"],
|
104 |
"colors": ["#00BFFF", "#FFD700", "#FF6347"],
|
105 |
"mood": "역동적이고 시원한"
|
106 |
},
|
107 |
"8월": {
|
108 |
+
"holidays": ["���복절"],
|
109 |
"special_days": ["그린데이", "바캉스", "여름 끝"],
|
110 |
+
"seasonal_terms": ["입추", "처서", "말복"], # 말복 포함
|
111 |
"trends": ["여름휴가절정", "바다여행", "축제", "여름추억", "해외여행"],
|
112 |
"seasons": ["한여름", "무더위", "휴가철"],
|
113 |
"colors": ["#00BFFF", "#FF6347", "#FFD700"],
|
114 |
"mood": "열정적이고 추억가득한"
|
115 |
},
|
116 |
"9월": {
|
117 |
+
"holidays": ["추석"],
|
118 |
"special_days": ["포토데이", "뮤직데이", "한가위"],
|
119 |
+
"seasonal_terms": ["백로", "추분"],
|
120 |
"trends": ["추석준비", "가을패션", "독서", "문화생활", "전통"],
|
121 |
"seasons": ["가을", "추석", "선선함"],
|
122 |
"colors": ["#FF8C00", "#DC143C", "#B8860B"],
|
|
|
125 |
"10월": {
|
126 |
"holidays": ["개천절", "한글날"],
|
127 |
"special_days": ["와인데이", "커피데이", "독서의 달"],
|
128 |
+
"seasonal_terms": ["한로", "상강"],
|
129 |
"trends": ["가을단풍", "독서", "카페문화", "가을나들이", "문화예술"],
|
130 |
"seasons": ["단풍", "가을정취", "쌀쌀함"],
|
131 |
"colors": ["#FF8C00", "#DC143C", "#B8860B"],
|
|
|
134 |
"11월": {
|
135 |
"holidays": ["빼빼로데이", "수능"],
|
136 |
"special_days": ["무비데이", "오렌지데이", "김장철"],
|
137 |
+
"seasonal_terms": ["입동", "소설"],
|
138 |
"trends": ["빼빼로데이", "수능응원", "겨울준비", "연말준비", "감사"],
|
139 |
"seasons": ["늦가을", "쌀쌀함", "겨울준비"],
|
140 |
"colors": ["#8B4513", "#A0522D", "#CD853F"],
|
|
|
143 |
"12월": {
|
144 |
"holidays": ["크리스마스", "성탄절", "동지"],
|
145 |
"special_days": ["허그데이", "키스데이", "연말"],
|
146 |
+
"seasonal_terms": ["대설", "동지", "소한"],
|
147 |
"trends": ["크리스마스", "연말파티", "선물", "한해마무리", "송년회"],
|
148 |
"seasons": ["겨울", "연말", "눈"],
|
149 |
"colors": ["#DC143C", "#228B22", "#FFD700"],
|
|
|
153 |
|
154 |
data = monthly_data.get(month, {})
|
155 |
|
156 |
+
# 6가지 상세 컨셉 생성 (절기 컨셉 추가)
|
157 |
concepts = []
|
158 |
|
159 |
# 컨셉 1: 주요 기념일 기반
|
|
|
170 |
"participation_factor": "기념일 특별감, 시즌성"
|
171 |
})
|
172 |
|
173 |
+
# 컨셉 2: 절기 기반 (새로 추가)
|
174 |
+
if data.get("seasonal_terms"):
|
175 |
+
main_term = data["seasonal_terms"][0]
|
176 |
+
concepts.append({
|
177 |
+
"name": f"{main_term} 절기 이벤트",
|
178 |
+
"theme": f"24절기 {main_term}의 의미를 담은 전통 감성 이벤트",
|
179 |
+
"score": 7.3,
|
180 |
+
"reason": f"전통 절기 {main_term}로 한국적 정서와 계절감 어필",
|
181 |
+
"target": "전연령대, 전통문화 관심층, 자연친화적 성향",
|
182 |
+
"colors": data.get("colors", ["#8FBC8F"]),
|
183 |
+
"keywords": data.get("seasonal_terms", [])[:2] + ["전통", "자연"],
|
184 |
+
"participation_factor": "전통적 가치, 자연 친화성"
|
185 |
+
})
|
186 |
+
|
187 |
+
# 컨셉 3: 트렌드 기반
|
188 |
if data.get("trends"):
|
189 |
main_trend = data["trends"][0]
|
190 |
concepts.append({
|
|
|
198 |
"participation_factor": "트렌드 화제성, SNS 확산성"
|
199 |
})
|
200 |
|
201 |
+
# 컨셉 4: 계절감 기반
|
202 |
if data.get("seasons"):
|
203 |
season = data["seasons"][0]
|
204 |
concepts.append({
|
|
|
212 |
"participation_factor": "계절 공감대, 일상 연관성"
|
213 |
})
|
214 |
|
215 |
+
# 컨셉 5: 스페셜 데이 기반
|
216 |
if data.get("special_days"):
|
217 |
special = data["special_days"][0]
|
218 |
concepts.append({
|
|
|
226 |
"participation_factor": "특별함 기대, 혜택 매력도"
|
227 |
})
|
228 |
|
229 |
+
# 컨셉 6: 커뮤니티 소통 기반
|
230 |
concepts.append({
|
231 |
"name": f"{month} 우리들의 이야기",
|
232 |
"theme": "커뮤니티 멤버 간 소통과 공감 이벤트",
|
|
|
239 |
})
|
240 |
|
241 |
# 결과 텍스트 생성
|
242 |
+
result = f"# 🎯 {month} 고도화된 컨셉 분석 (절기 포함)\n\n"
|
243 |
result += f"**📊 분석 기준:** {data.get('mood', '특별한')} 분위기\n"
|
244 |
result += f"**🎨 주요 색상:** {', '.join(data.get('colors', ['기본색상'])[:3])}\n"
|
245 |
+
result += f"**🔥 핵심 트렌드:** {', '.join(data.get('trends', ['기본트렌드'])[:3])}\n"
|
246 |
+
result += f"**🌿 해당 절기:** {', '.join(data.get('seasonal_terms', ['해당없음']))}\n\n"
|
247 |
|
248 |
concept_names = []
|
249 |
|
|
|
339 |
|
340 |
event_period_input = gr.Textbox(
|
341 |
label="이벤트 기간",
|
342 |
+
placeholder="예: 2024.12.01 ~ 2024.12.07 (월이 자동 인식됩니다)",
|
343 |
+
info="이벤트 기간을 입력하면 해당 월이 자동으로 선택됩니다"
|
344 |
)
|
345 |
|
346 |
month_dropdown = gr.Dropdown(
|
347 |
choices=[f"{i}월" for i in range(1, 13)],
|
348 |
label="이벤트 월 선택",
|
349 |
+
value="1월",
|
350 |
+
info="이벤트 기간에서 자동 인식되거나 직접 선택"
|
351 |
)
|
352 |
|
353 |
analyze_btn = gr.Button("컨셉 분석하기", variant="primary")
|