Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -146,7 +146,6 @@ Always add this text at the beginning:
|
|
| 146 |
}
|
| 147 |
|
| 148 |
try:
|
| 149 |
-
# API call takes time, so we don't need to add artificial delay
|
| 150 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=90)
|
| 151 |
|
| 152 |
if response.status_code == 200:
|
|
@@ -194,261 +193,6 @@ def calculate_cost(token_usage):
|
|
| 194 |
"total_cost": total_cost
|
| 195 |
}
|
| 196 |
|
| 197 |
-
# House transformation animation
|
| 198 |
-
house_animation_html = """
|
| 199 |
-
<style>
|
| 200 |
-
/* House Animation Container */
|
| 201 |
-
.house-animation-container {
|
| 202 |
-
display: flex;
|
| 203 |
-
justify-content: center;
|
| 204 |
-
align-items: center;
|
| 205 |
-
height: 250px;
|
| 206 |
-
overflow: hidden;
|
| 207 |
-
margin: 20px 0;
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
/* House SVG Styling */
|
| 211 |
-
.house-svg {
|
| 212 |
-
width: 200px;
|
| 213 |
-
height: 200px;
|
| 214 |
-
}
|
| 215 |
-
|
| 216 |
-
/* House Parts */
|
| 217 |
-
.house-base {
|
| 218 |
-
fill: #e0e0e0;
|
| 219 |
-
transition: fill 2s ease-in-out;
|
| 220 |
-
animation: colorChange 4s infinite alternate;
|
| 221 |
-
}
|
| 222 |
-
|
| 223 |
-
.house-roof {
|
| 224 |
-
fill: #b71c1c;
|
| 225 |
-
transition: fill 2s ease-in-out;
|
| 226 |
-
animation: roofColorChange 4s infinite alternate;
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
.house-door {
|
| 230 |
-
fill: #5d4037;
|
| 231 |
-
transition: fill 2s ease-in-out;
|
| 232 |
-
animation: doorAnimate 4s infinite alternate;
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
.house-window {
|
| 236 |
-
fill: #bbdefb;
|
| 237 |
-
transition: fill 2s ease-in-out;
|
| 238 |
-
animation: windowLight 4s infinite alternate;
|
| 239 |
-
}
|
| 240 |
-
|
| 241 |
-
/* Animation for the entire house */
|
| 242 |
-
.house-container {
|
| 243 |
-
animation: houseGrow 1s infinite alternate;
|
| 244 |
-
transform-origin: center bottom;
|
| 245 |
-
}
|
| 246 |
-
|
| 247 |
-
/* Analysis text animation */
|
| 248 |
-
.analysis-text {
|
| 249 |
-
text-align: center;
|
| 250 |
-
font-size: 18px;
|
| 251 |
-
font-weight: bold;
|
| 252 |
-
margin-top: 20px;
|
| 253 |
-
animation: textFade 2s infinite alternate;
|
| 254 |
-
color: #1976d2;
|
| 255 |
-
}
|
| 256 |
-
|
| 257 |
-
/* Workers and tools animations */
|
| 258 |
-
.worker {
|
| 259 |
-
fill: #795548;
|
| 260 |
-
animation: workerMove 4s infinite alternate;
|
| 261 |
-
}
|
| 262 |
-
|
| 263 |
-
.ladder {
|
| 264 |
-
fill: #8d6e63;
|
| 265 |
-
animation: ladderMove 4s infinite alternate-reverse;
|
| 266 |
-
}
|
| 267 |
-
|
| 268 |
-
.paint-brush {
|
| 269 |
-
fill: #ff9800;
|
| 270 |
-
animation: toolAnimate 3s infinite;
|
| 271 |
-
}
|
| 272 |
-
|
| 273 |
-
/* Improvement elements appear one by one */
|
| 274 |
-
.improvement {
|
| 275 |
-
opacity: 0;
|
| 276 |
-
animation: fadeIn 10s forwards;
|
| 277 |
-
}
|
| 278 |
-
|
| 279 |
-
.improvement-1 { animation-delay: 1s; }
|
| 280 |
-
.improvement-2 { animation-delay: 3s; }
|
| 281 |
-
.improvement-3 { animation-delay: 5s; }
|
| 282 |
-
.improvement-4 { animation-delay: 7s; }
|
| 283 |
-
|
| 284 |
-
/* Keyframes for animations */
|
| 285 |
-
@keyframes colorChange {
|
| 286 |
-
0% { fill: #e0e0e0; }
|
| 287 |
-
50% { fill: #f5f5f5; }
|
| 288 |
-
100% { fill: #eeeeee; }
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
@keyframes roofColorChange {
|
| 292 |
-
0% { fill: #b71c1c; }
|
| 293 |
-
50% { fill: #c62828; }
|
| 294 |
-
100% { fill: #d32f2f; }
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
@keyframes doorAnimate {
|
| 298 |
-
0% { fill: #5d4037; }
|
| 299 |
-
50% { fill: #6d4c41; transform: scaleY(1); }
|
| 300 |
-
100% { fill: #795548; transform: scaleY(1.02); }
|
| 301 |
-
}
|
| 302 |
-
|
| 303 |
-
@keyframes windowLight {
|
| 304 |
-
0% { fill: #bbdefb; }
|
| 305 |
-
50% { fill: #90caf9; }
|
| 306 |
-
100% { fill: #64b5f6; }
|
| 307 |
-
}
|
| 308 |
-
|
| 309 |
-
@keyframes houseGrow {
|
| 310 |
-
0% { transform: scale(1); }
|
| 311 |
-
100% { transform: scale(1.02); }
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
@keyframes textFade {
|
| 315 |
-
0% { opacity: 0.7; }
|
| 316 |
-
100% { opacity: 1; }
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
@keyframes workerMove {
|
| 320 |
-
0% { transform: translateX(0); }
|
| 321 |
-
100% { transform: translateX(30px); }
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
@keyframes ladderMove {
|
| 325 |
-
0% { transform: rotate(0deg); }
|
| 326 |
-
100% { transform: rotate(5deg); }
|
| 327 |
-
}
|
| 328 |
-
|
| 329 |
-
@keyframes toolAnimate {
|
| 330 |
-
0% { transform: rotate(0deg); }
|
| 331 |
-
50% { transform: rotate(-20deg); }
|
| 332 |
-
100% { transform: rotate(0deg); }
|
| 333 |
-
}
|
| 334 |
-
|
| 335 |
-
@keyframes fadeIn {
|
| 336 |
-
0% { opacity: 0; }
|
| 337 |
-
50% { opacity: 0.5; }
|
| 338 |
-
100% { opacity: 1; }
|
| 339 |
-
}
|
| 340 |
-
|
| 341 |
-
/* Loading dots animation */
|
| 342 |
-
.loading-dots:after {
|
| 343 |
-
content: '.';
|
| 344 |
-
animation: dots 1.5s steps(5, end) infinite;
|
| 345 |
-
}
|
| 346 |
-
|
| 347 |
-
@keyframes dots {
|
| 348 |
-
0%, 20% { content: '.'; }
|
| 349 |
-
40% { content: '..'; }
|
| 350 |
-
60% { content: '...'; }
|
| 351 |
-
80%, 100% { content: ''; }
|
| 352 |
-
}
|
| 353 |
-
|
| 354 |
-
/* Progress bar */
|
| 355 |
-
.progress-container {
|
| 356 |
-
width: 100%;
|
| 357 |
-
background-color: #f1f1f1;
|
| 358 |
-
border-radius: 5px;
|
| 359 |
-
margin-top: 20px;
|
| 360 |
-
}
|
| 361 |
-
|
| 362 |
-
.progress-bar {
|
| 363 |
-
width: 1%;
|
| 364 |
-
height: 10px;
|
| 365 |
-
background-color: #4CAF50;
|
| 366 |
-
border-radius: 5px;
|
| 367 |
-
animation: progressAnimate 20s linear;
|
| 368 |
-
}
|
| 369 |
-
|
| 370 |
-
@keyframes progressAnimate {
|
| 371 |
-
0% { width: 5%; }
|
| 372 |
-
20% { width: 25%; }
|
| 373 |
-
50% { width: 55%; }
|
| 374 |
-
80% { width: 80%; }
|
| 375 |
-
100% { width: 100%; }
|
| 376 |
-
}
|
| 377 |
-
|
| 378 |
-
/* Analysis phases */
|
| 379 |
-
.phase {
|
| 380 |
-
opacity: 0;
|
| 381 |
-
animation: phaseShow 20s linear forwards;
|
| 382 |
-
margin: 5px 0;
|
| 383 |
-
font-size: 14px;
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
.phase-1 { animation-delay: 0s; }
|
| 387 |
-
.phase-2 { animation-delay: 5s; }
|
| 388 |
-
.phase-3 { animation-delay: 10s; }
|
| 389 |
-
.phase-4 { animation-delay: 15s; }
|
| 390 |
-
|
| 391 |
-
@keyframes phaseShow {
|
| 392 |
-
0% { opacity: 0; }
|
| 393 |
-
5% { opacity: 1; }
|
| 394 |
-
20% { opacity: 1; }
|
| 395 |
-
25% { opacity: 0.4; }
|
| 396 |
-
100% { opacity: 0.4; }
|
| 397 |
-
}
|
| 398 |
-
</style>
|
| 399 |
-
|
| 400 |
-
<div class="house-animation-container">
|
| 401 |
-
<div>
|
| 402 |
-
<svg class="house-svg" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
| 403 |
-
<!-- House Container -->
|
| 404 |
-
<g class="house-container">
|
| 405 |
-
<!-- House Base -->
|
| 406 |
-
<rect class="house-base" x="40" y="80" width="120" height="90" rx="2" />
|
| 407 |
-
|
| 408 |
-
<!-- House Roof -->
|
| 409 |
-
<polygon class="house-roof" points="30,80 100,30 170,80" />
|
| 410 |
-
|
| 411 |
-
<!-- Door -->
|
| 412 |
-
<rect class="house-door" x="85" y="120" width="30" height="50" rx="2" />
|
| 413 |
-
<circle fill="#ffd54f" cx="105" cy="145" r="2" /> <!-- Doorknob -->
|
| 414 |
-
|
| 415 |
-
<!-- Windows -->
|
| 416 |
-
<rect class="house-window" x="55" y="100" width="20" height="20" rx="2" />
|
| 417 |
-
<rect class="house-window" x="125" y="100" width="20" height="20" rx="2" />
|
| 418 |
-
<line x1="65" y1="100" x2="65" y2="120" stroke="#bdbdbd" stroke-width="1" />
|
| 419 |
-
<line x1="55" y1="110" x2="75" y2="110" stroke="#bdbdbd" stroke-width="1" />
|
| 420 |
-
<line x1="135" y1="100" x2="135" y2="120" stroke="#bdbdbd" stroke-width="1" />
|
| 421 |
-
<line x1="125" y1="110" x2="145" y2="110" stroke="#bdbdbd" stroke-width="1" />
|
| 422 |
-
|
| 423 |
-
<!-- Improvements Animation Elements -->
|
| 424 |
-
<rect class="improvement improvement-1" x="30" y="170" width="140" height="5" fill="#8d6e63" /> <!-- New walkway -->
|
| 425 |
-
<rect class="improvement improvement-2" x="30" y="77" width="140" height="3" fill="#0288d1" /> <!-- New gutters -->
|
| 426 |
-
<circle class="improvement improvement-3" cx="160" cy="150" r="10" fill="#81c784" /> <!-- New plants -->
|
| 427 |
-
<circle class="improvement improvement-4" cx="40" cy="150" r="10" fill="#81c784" /> <!-- New plants -->
|
| 428 |
-
|
| 429 |
-
<!-- Workers -->
|
| 430 |
-
<circle class="worker" cx="50" cy="140" r="5" />
|
| 431 |
-
<rect class="ladder" x="150" y="100" width="5" height="40" />
|
| 432 |
-
<rect class="paint-brush" x="155" y="110" width="10" height="2" transform="rotate(45, 155, 110)" />
|
| 433 |
-
</g>
|
| 434 |
-
</svg>
|
| 435 |
-
|
| 436 |
-
<div class="analysis-text">
|
| 437 |
-
<span class="loading-dots">Analyzing your home</span>
|
| 438 |
-
</div>
|
| 439 |
-
|
| 440 |
-
<div class="progress-container">
|
| 441 |
-
<div class="progress-bar"></div>
|
| 442 |
-
</div>
|
| 443 |
-
|
| 444 |
-
<div class="phase phase-1">✓ Identifying property features...</div>
|
| 445 |
-
<div class="phase phase-2">✓ Evaluating improvement opportunities...</div>
|
| 446 |
-
<div class="phase phase-3">✓ Calculating ROI potential...</div>
|
| 447 |
-
<div class="phase phase-4">✓ Preparing final recommendations...</div>
|
| 448 |
-
</div>
|
| 449 |
-
</div>
|
| 450 |
-
"""
|
| 451 |
-
|
| 452 |
# Main application
|
| 453 |
st.title("Home Value Maximizer 🏡")
|
| 454 |
|
|
@@ -654,24 +398,45 @@ with col2:
|
|
| 654 |
if analyze_button or "analysis_result" in st.session_state:
|
| 655 |
# Process analysis if button pressed
|
| 656 |
if analyze_button:
|
| 657 |
-
#
|
| 658 |
-
st.
|
| 659 |
-
|
| 660 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
analysis_text = analyze_home_photos(
|
| 662 |
st.session_state["uploaded_images"],
|
| 663 |
timeframe,
|
| 664 |
f"Budget: ${max_budget}. Focus areas: {', '.join(improvement_focus)}. DIY preference: {diy_preference}. {additional_details}",
|
| 665 |
st.session_state["api_key"]
|
| 666 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
st.session_state["analysis_result"] = analysis_text
|
|
|
|
|
|
|
| 668 |
|
| 669 |
# Display results
|
| 670 |
if "analysis_result" in st.session_state:
|
| 671 |
-
# If we just analyzed, the animation is still showing, so we need to clear it
|
| 672 |
-
if analyze_button:
|
| 673 |
-
st.empty() # Clear the animation
|
| 674 |
-
|
| 675 |
result = st.session_state["analysis_result"]
|
| 676 |
st.markdown(f'<div class="results-container">{result}</div>', unsafe_allow_html=True)
|
| 677 |
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
try:
|
|
|
|
| 149 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=90)
|
| 150 |
|
| 151 |
if response.status_code == 200:
|
|
|
|
| 193 |
"total_cost": total_cost
|
| 194 |
}
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
# Main application
|
| 197 |
st.title("Home Value Maximizer 🏡")
|
| 198 |
|
|
|
|
| 398 |
if analyze_button or "analysis_result" in st.session_state:
|
| 399 |
# Process analysis if button pressed
|
| 400 |
if analyze_button:
|
| 401 |
+
# Simple loading indicator using pure Streamlit - no HTML, JS or CSS
|
| 402 |
+
with st.spinner("🏡 Analyzing your home photos..."):
|
| 403 |
+
# Show a progress bar
|
| 404 |
+
progress_bar = st.progress(0)
|
| 405 |
+
|
| 406 |
+
# Show the analysis steps with native Streamlit components
|
| 407 |
+
steps_placeholder = st.empty()
|
| 408 |
+
steps_placeholder.info("Step 1: Identifying property features...")
|
| 409 |
+
progress_bar.progress(25)
|
| 410 |
+
time.sleep(1) # Small delay for visual effect
|
| 411 |
+
|
| 412 |
+
steps_placeholder.info("Step 2: Evaluating improvement opportunities...")
|
| 413 |
+
progress_bar.progress(50)
|
| 414 |
+
time.sleep(1) # Small delay for visual effect
|
| 415 |
+
|
| 416 |
+
steps_placeholder.info("Step 3: Calculating ROI potential...")
|
| 417 |
+
progress_bar.progress(75)
|
| 418 |
+
time.sleep(1) # Small delay for visual effect
|
| 419 |
+
|
| 420 |
+
steps_placeholder.info("Step 4: Preparing final recommendations...")
|
| 421 |
+
|
| 422 |
+
# Make the actual API call
|
| 423 |
analysis_text = analyze_home_photos(
|
| 424 |
st.session_state["uploaded_images"],
|
| 425 |
timeframe,
|
| 426 |
f"Budget: ${max_budget}. Focus areas: {', '.join(improvement_focus)}. DIY preference: {diy_preference}. {additional_details}",
|
| 427 |
st.session_state["api_key"]
|
| 428 |
)
|
| 429 |
+
|
| 430 |
+
# Complete the progress bar
|
| 431 |
+
progress_bar.progress(100)
|
| 432 |
+
|
| 433 |
+
# Store the result and clear the loading indicators
|
| 434 |
st.session_state["analysis_result"] = analysis_text
|
| 435 |
+
steps_placeholder.empty()
|
| 436 |
+
progress_bar.empty()
|
| 437 |
|
| 438 |
# Display results
|
| 439 |
if "analysis_result" in st.session_state:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
result = st.session_state["analysis_result"]
|
| 441 |
st.markdown(f'<div class="results-container">{result}</div>', unsafe_allow_html=True)
|
| 442 |
|