Dexter Edep
commited on
Commit
·
71c2730
1
Parent(s):
3b2eac4
Update UI
Browse files- README.md +42 -5
- app.py +34 -4
- gradio-ui/app.py +1 -8
- gradio-ui/components/costs_display.py +7 -7
- gradio-ui/components/facilities_map.py +18 -18
- gradio-ui/components/recommendations_display.py +5 -5
- gradio-ui/components/risk_display.py +5 -5
- gradio-ui/export_utils.py +1 -1
- requirements.txt +11 -0
README.md
CHANGED
|
@@ -1,12 +1,49 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.0.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Disaster Risk Construction Planner
|
| 3 |
+
emoji: 🏗️
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.0.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# 🏗️ Disaster Risk Construction Planner
|
| 13 |
+
|
| 14 |
+
Plan disaster-resistant construction in the Philippines with AI-powered risk assessment, recommendations, cost analysis, and facility mapping.
|
| 15 |
+
|
| 16 |
+
## Features
|
| 17 |
+
|
| 18 |
+
- **Risk Assessment**: Analyze seismic, volcanic, and hydrometeorological hazards
|
| 19 |
+
- **Construction Recommendations**: Get building-specific guidance for disaster resistance
|
| 20 |
+
- **Cost Analysis**: Estimate material costs for disaster-resistant construction
|
| 21 |
+
- **Facility Mapping**: Locate nearby schools, hospitals, and emergency services
|
| 22 |
+
- **Export Options**: Download plans as JSON or PDF
|
| 23 |
+
|
| 24 |
+
## How to Use
|
| 25 |
+
|
| 26 |
+
1. **Select Building Type**: Choose from residential, commercial, industrial, institutional, or mixed-use
|
| 27 |
+
2. **Enter Coordinates**: Provide latitude and longitude within Philippine bounds (4°N-21°N, 116°E-127°E)
|
| 28 |
+
3. **Specify Building Area** (optional): Enter estimated building area in square meters
|
| 29 |
+
4. **Generate Plan**: Click "Generate Construction Plan" button
|
| 30 |
+
5. **Review Results**: Navigate through tabs to view different aspects of the plan
|
| 31 |
+
6. **Export**: Use export buttons to save the plan
|
| 32 |
+
|
| 33 |
+
## Example Locations
|
| 34 |
+
|
| 35 |
+
- **Manila**: 14.5995°N, 120.9842°E
|
| 36 |
+
- **Cebu**: 10.3157°N, 123.8854°E
|
| 37 |
+
- **Davao**: 7.1907°N, 125.4553°E
|
| 38 |
+
|
| 39 |
+
## Technology
|
| 40 |
+
|
| 41 |
+
Built with:
|
| 42 |
+
- Gradio 6 for the web interface
|
| 43 |
+
- AI agents for orchestration and analysis
|
| 44 |
+
- Philippines Disaster Risk data
|
| 45 |
+
- Google Maps API for facility location
|
| 46 |
+
|
| 47 |
+
## Disclaimer
|
| 48 |
+
|
| 49 |
+
This tool provides guidance only. Always consult with licensed engineers, architects, and local authorities for actual construction projects.
|
app.py
CHANGED
|
@@ -1,7 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Disaster Risk Construction Planner - Hugging Face Deployment Entry Point
|
| 3 |
+
This file serves as the entry point for Hugging Face Spaces deployment.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import sys
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
# Add gradio-ui and shared directories to Python path
|
| 10 |
+
current_dir = Path(__file__).parent
|
| 11 |
+
gradio_ui_path = current_dir / "gradio-ui"
|
| 12 |
+
shared_path = current_dir / "shared"
|
| 13 |
+
|
| 14 |
+
sys.path.insert(0, str(gradio_ui_path))
|
| 15 |
+
sys.path.insert(0, str(shared_path))
|
| 16 |
+
sys.path.insert(0, str(current_dir))
|
| 17 |
+
|
| 18 |
+
# Import and launch the Gradio UI
|
| 19 |
import gradio as gr
|
| 20 |
|
| 21 |
+
# Import the create_interface function from gradio-ui/app.py
|
| 22 |
+
import importlib.util
|
| 23 |
+
spec = importlib.util.spec_from_file_location("gradio_app", gradio_ui_path / "app.py")
|
| 24 |
+
gradio_app = importlib.util.module_from_spec(spec)
|
| 25 |
+
spec.loader.exec_module(gradio_app)
|
| 26 |
+
|
| 27 |
+
# Create the interface
|
| 28 |
+
app = gradio_app.create_interface()
|
| 29 |
|
| 30 |
+
# Launch configuration for Hugging Face Spaces
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
app.launch(
|
| 33 |
+
server_name="0.0.0.0",
|
| 34 |
+
server_port=7860,
|
| 35 |
+
share=False,
|
| 36 |
+
theme=gr.themes.Soft()
|
| 37 |
+
)
|
gradio-ui/app.py
CHANGED
|
@@ -170,7 +170,6 @@ def process_construction_plan(
|
|
| 170 |
return (
|
| 171 |
status_html,
|
| 172 |
risk_html,
|
| 173 |
-
hazards_html,
|
| 174 |
recommendations_html,
|
| 175 |
costs_html,
|
| 176 |
facilities_html
|
|
@@ -211,7 +210,7 @@ def _format_status(construction_plan) -> str:
|
|
| 211 |
|
| 212 |
html = f"""
|
| 213 |
<div style="padding: 20px;">
|
| 214 |
-
<h2 style="margin-top: 0; color: #
|
| 215 |
|
| 216 |
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;">
|
| 217 |
<h3 style="color: #1e40af !important; margin-top: 0; font-weight: 600;">📋 Project Information</h3>
|
|
@@ -382,11 +381,6 @@ def create_interface():
|
|
| 382 |
value="<p style='text-align: center; color: #6b7280; padding: 40px;'>Risk assessment will appear here</p>"
|
| 383 |
)
|
| 384 |
|
| 385 |
-
with gr.Tab("⚠️ Hazards"):
|
| 386 |
-
hazards_output = gr.HTML(
|
| 387 |
-
label="Detailed Hazards",
|
| 388 |
-
value="<p style='text-align: center; color: #6b7280; padding: 40px;'>Detailed hazard information will appear here</p>"
|
| 389 |
-
)
|
| 390 |
|
| 391 |
with gr.Tab("📋 Recommendations"):
|
| 392 |
recommendations_output = gr.HTML(
|
|
@@ -447,7 +441,6 @@ def create_interface():
|
|
| 447 |
outputs=[
|
| 448 |
status_output,
|
| 449 |
risk_output,
|
| 450 |
-
hazards_output,
|
| 451 |
recommendations_output,
|
| 452 |
costs_output,
|
| 453 |
facilities_output
|
|
|
|
| 170 |
return (
|
| 171 |
status_html,
|
| 172 |
risk_html,
|
|
|
|
| 173 |
recommendations_html,
|
| 174 |
costs_html,
|
| 175 |
facilities_html
|
|
|
|
| 210 |
|
| 211 |
html = f"""
|
| 212 |
<div style="padding: 20px;">
|
| 213 |
+
<h2 style="margin-top: 0; color: #ffffff !important; font-weight: 700;">📊 Construction Plan Summary</h2>
|
| 214 |
|
| 215 |
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;">
|
| 216 |
<h3 style="color: #1e40af !important; margin-top: 0; font-weight: 600;">📋 Project Information</h3>
|
|
|
|
| 381 |
value="<p style='text-align: center; color: #6b7280; padding: 40px;'>Risk assessment will appear here</p>"
|
| 382 |
)
|
| 383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
with gr.Tab("📋 Recommendations"):
|
| 386 |
recommendations_output = gr.HTML(
|
|
|
|
| 441 |
outputs=[
|
| 442 |
status_output,
|
| 443 |
risk_output,
|
|
|
|
| 444 |
recommendations_output,
|
| 445 |
costs_output,
|
| 446 |
facilities_output
|
gradio-ui/components/costs_display.py
CHANGED
|
@@ -33,7 +33,7 @@ def format_costs_display(cost_data) -> str:
|
|
| 33 |
|
| 34 |
html = """
|
| 35 |
<div style="padding: 20px;">
|
| 36 |
-
<h2 style="margin-top: 0; color: #
|
| 37 |
"""
|
| 38 |
|
| 39 |
# Total Cost Estimate - handle both dict and object
|
|
@@ -77,13 +77,13 @@ def format_costs_display(cost_data) -> str:
|
|
| 77 |
|
| 78 |
if market_conditions or last_updated:
|
| 79 |
html += """
|
| 80 |
-
<div style="background:
|
| 81 |
-
<h4 style="margin-top: 0; color: #d97706;">📊 Market Information</h4>
|
| 82 |
"""
|
| 83 |
if market_conditions:
|
| 84 |
-
html += f"<p style='margin: 5px 0;'><strong>Market Conditions:</strong> {market_conditions}</p>"
|
| 85 |
if last_updated:
|
| 86 |
-
html += f"<p style='margin: 5px 0;'><strong>Last Updated:</strong> {last_updated}</p>"
|
| 87 |
html += """
|
| 88 |
</div>
|
| 89 |
"""
|
|
@@ -164,8 +164,8 @@ def format_costs_display(cost_data) -> str:
|
|
| 164 |
|
| 165 |
# Disclaimer
|
| 166 |
html += """
|
| 167 |
-
<div style="background:
|
| 168 |
-
<p style="margin: 0;"><strong>Note:</strong> Cost estimates are based on current market conditions and may vary.
|
| 169 |
Actual costs depend on supplier, location, quantity discounts, and market fluctuations.
|
| 170 |
Please consult with local suppliers for accurate quotes.</p>
|
| 171 |
</div>
|
|
|
|
| 33 |
|
| 34 |
html = """
|
| 35 |
<div style="padding: 20px;">
|
| 36 |
+
<h2 style="margin-top: 0; color: #ffffff !important; font-weight: 700;">💰 Material Cost Analysis</h2>
|
| 37 |
"""
|
| 38 |
|
| 39 |
# Total Cost Estimate - handle both dict and object
|
|
|
|
| 77 |
|
| 78 |
if market_conditions or last_updated:
|
| 79 |
html += """
|
| 80 |
+
<div style="background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid #f59e0b; border: 1px solid #fde68a;">
|
| 81 |
+
<h4 style="margin-top: 0; color: #d97706 !important;">📊 Market Information</h4>
|
| 82 |
"""
|
| 83 |
if market_conditions:
|
| 84 |
+
html += f"<p style='margin: 5px 0; color: #0f172a !important;'><strong style='color: #0f172a !important;'>Market Conditions:</strong> {market_conditions}</p>"
|
| 85 |
if last_updated:
|
| 86 |
+
html += f"<p style='margin: 5px 0; color: #0f172a !important;'><strong style='color: #0f172a !important;'>Last Updated:</strong> {last_updated}</p>"
|
| 87 |
html += """
|
| 88 |
</div>
|
| 89 |
"""
|
|
|
|
| 164 |
|
| 165 |
# Disclaimer
|
| 166 |
html += """
|
| 167 |
+
<div style="background: white; padding: 15px; border-radius: 8px; margin-top: 20px; font-size: 0.9em; border: 1px solid #e2e8f0;">
|
| 168 |
+
<p style="margin: 0; color: #0f172a !important;"><strong style="color: #0f172a !important;">Note:</strong> Cost estimates are based on current market conditions and may vary.
|
| 169 |
Actual costs depend on supplier, location, quantity discounts, and market fluctuations.
|
| 170 |
Please consult with local suppliers for accurate quotes.</p>
|
| 171 |
</div>
|
gradio-ui/components/facilities_map.py
CHANGED
|
@@ -34,7 +34,7 @@ def format_facilities_map(facility_data, site_coords = None) -> Tuple[str, str]:
|
|
| 34 |
|
| 35 |
html = """
|
| 36 |
<div style="padding: 20px;">
|
| 37 |
-
<h2 style="margin-top: 0; color: #
|
| 38 |
"""
|
| 39 |
|
| 40 |
# Building site info - handle both dict and object
|
|
@@ -42,9 +42,9 @@ def format_facilities_map(facility_data, site_coords = None) -> Tuple[str, str]:
|
|
| 42 |
lat = site_coords.get('latitude', 0) if isinstance(site_coords, dict) else getattr(site_coords, 'latitude', 0)
|
| 43 |
lon = site_coords.get('longitude', 0) if isinstance(site_coords, dict) else getattr(site_coords, 'longitude', 0)
|
| 44 |
html += f"""
|
| 45 |
-
<div style="background:
|
| 46 |
-
<h4 style="margin-top: 0; color: #1e40af;">🏗️ Building Site</h4>
|
| 47 |
-
<p style="margin: 5px 0;">Coordinates
|
| 48 |
</div>
|
| 49 |
"""
|
| 50 |
|
|
@@ -92,10 +92,10 @@ def format_facilities_map(facility_data, site_coords = None) -> Tuple[str, str]:
|
|
| 92 |
<h3 style="color: #6b7280; margin-top: 0;">🛣️ Road Networks</h3>
|
| 93 |
<table style="width: 100%; border-collapse: collapse;">
|
| 94 |
<thead>
|
| 95 |
-
<tr style="background: #
|
| 96 |
-
<th style="padding: 10px; text-align: left; border-bottom: 2px solid #
|
| 97 |
-
<th style="padding: 10px; text-align: left; border-bottom: 2px solid #
|
| 98 |
-
<th style="padding: 10px; text-align: right; border-bottom: 2px solid #
|
| 99 |
</tr>
|
| 100 |
</thead>
|
| 101 |
<tbody>
|
|
@@ -107,14 +107,14 @@ def format_facilities_map(facility_data, site_coords = None) -> Tuple[str, str]:
|
|
| 107 |
distance_meters = road.get('distance_meters', 0) if isinstance(road, dict) else getattr(road, 'distance_meters', 0)
|
| 108 |
|
| 109 |
html += f"""
|
| 110 |
-
<tr style="border-bottom: 1px solid #
|
| 111 |
-
<td style="padding: 10px;"><strong>{road_name}</strong></td>
|
| 112 |
<td style="padding: 10px;">
|
| 113 |
-
<span style="background: #
|
| 114 |
{road_type.upper()}
|
| 115 |
</span>
|
| 116 |
</td>
|
| 117 |
-
<td style="padding: 10px; text-align: right;">{distance_meters / 1000:.2f} km</td>
|
| 118 |
</tr>
|
| 119 |
"""
|
| 120 |
html += """
|
|
@@ -261,8 +261,8 @@ def _prepare_map_data(facility_data, site_coords = None) -> str:
|
|
| 261 |
📍 Open in Google Maps
|
| 262 |
</a>
|
| 263 |
</p>
|
| 264 |
-
<div style="margin-top: 15px; padding: 15px; background:
|
| 265 |
-
<p style="margin: 0; color: #
|
| 266 |
Map visualization shows the building site and nearby critical facilities.
|
| 267 |
Click the link above to view an interactive map with all locations.
|
| 268 |
</p>
|
|
@@ -311,11 +311,11 @@ def format_facilities_list(facility_data) -> str:
|
|
| 311 |
travel_time_minutes = facility.get('travel_time_minutes', 0) if isinstance(facility, dict) else getattr(facility, 'travel_time_minutes', 0)
|
| 312 |
|
| 313 |
html += f"""
|
| 314 |
-
<div style="margin-bottom: 10px; padding: 10px; background:
|
| 315 |
-
<strong>{name}</strong>
|
| 316 |
-
<span style="color: {color};">({category})</span>
|
| 317 |
<br>
|
| 318 |
-
<span style="font-size: 0.9em; color: #
|
| 319 |
{distance_meters / 1000:.2f} km • ~{travel_time_minutes:.0f} min
|
| 320 |
</span>
|
| 321 |
</div>
|
|
|
|
| 34 |
|
| 35 |
html = """
|
| 36 |
<div style="padding: 20px;">
|
| 37 |
+
<h2 style="margin-top: 0; color: #ffffff !important; font-weight: 700;">📍 Critical Facilities</h2>
|
| 38 |
"""
|
| 39 |
|
| 40 |
# Building site info - handle both dict and object
|
|
|
|
| 42 |
lat = site_coords.get('latitude', 0) if isinstance(site_coords, dict) else getattr(site_coords, 'latitude', 0)
|
| 43 |
lon = site_coords.get('longitude', 0) if isinstance(site_coords, dict) else getattr(site_coords, 'longitude', 0)
|
| 44 |
html += f"""
|
| 45 |
+
<div style="background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid #2563eb; border: 1px solid #bfdbfe;">
|
| 46 |
+
<h4 style="margin-top: 0; color: #1e40af !important;">🏗️ Building Site</h4>
|
| 47 |
+
<p style="margin: 5px 0; color: #0f172a !important;"><strong style="color: #0f172a !important;">Coordinates:</strong> {lat:.4f}°N, {lon:.4f}°E</p>
|
| 48 |
</div>
|
| 49 |
"""
|
| 50 |
|
|
|
|
| 92 |
<h3 style="color: #6b7280; margin-top: 0;">🛣️ Road Networks</h3>
|
| 93 |
<table style="width: 100%; border-collapse: collapse;">
|
| 94 |
<thead>
|
| 95 |
+
<tr style="background: #f8fafc;">
|
| 96 |
+
<th style="padding: 10px; text-align: left; border-bottom: 2px solid #cbd5e1; color: #0f172a !important; font-weight: 600;">Road Name</th>
|
| 97 |
+
<th style="padding: 10px; text-align: left; border-bottom: 2px solid #cbd5e1; color: #0f172a !important; font-weight: 600;">Type</th>
|
| 98 |
+
<th style="padding: 10px; text-align: right; border-bottom: 2px solid #cbd5e1; color: #0f172a !important; font-weight: 600;">Distance</th>
|
| 99 |
</tr>
|
| 100 |
</thead>
|
| 101 |
<tbody>
|
|
|
|
| 107 |
distance_meters = road.get('distance_meters', 0) if isinstance(road, dict) else getattr(road, 'distance_meters', 0)
|
| 108 |
|
| 109 |
html += f"""
|
| 110 |
+
<tr style="border-bottom: 1px solid #e2e8f0;">
|
| 111 |
+
<td style="padding: 10px; color: #0f172a !important;"><strong style="color: #0f172a !important;">{road_name}</strong></td>
|
| 112 |
<td style="padding: 10px;">
|
| 113 |
+
<span style="background: #e2e8f0; color: #0f172a !important; padding: 3px 8px; border-radius: 4px; font-size: 0.85em; font-weight: 600;">
|
| 114 |
{road_type.upper()}
|
| 115 |
</span>
|
| 116 |
</td>
|
| 117 |
+
<td style="padding: 10px; text-align: right; color: #0f172a !important;">{distance_meters / 1000:.2f} km</td>
|
| 118 |
</tr>
|
| 119 |
"""
|
| 120 |
html += """
|
|
|
|
| 261 |
📍 Open in Google Maps
|
| 262 |
</a>
|
| 263 |
</p>
|
| 264 |
+
<div style="margin-top: 15px; padding: 15px; background: white; border-radius: 6px; border: 1px solid #e2e8f0;">
|
| 265 |
+
<p style="margin: 0; color: #0f172a !important; font-size: 0.9em;">
|
| 266 |
Map visualization shows the building site and nearby critical facilities.
|
| 267 |
Click the link above to view an interactive map with all locations.
|
| 268 |
</p>
|
|
|
|
| 311 |
travel_time_minutes = facility.get('travel_time_minutes', 0) if isinstance(facility, dict) else getattr(facility, 'travel_time_minutes', 0)
|
| 312 |
|
| 313 |
html += f"""
|
| 314 |
+
<div style="margin-bottom: 10px; padding: 10px; background: white; border-left: 3px solid {color}; border-radius: 4px; border: 1px solid #e2e8f0;">
|
| 315 |
+
<strong style="color: #0f172a !important;">{name}</strong>
|
| 316 |
+
<span style="color: {color} !important;">({category})</span>
|
| 317 |
<br>
|
| 318 |
+
<span style="font-size: 0.9em; color: #0f172a !important;">
|
| 319 |
{distance_meters / 1000:.2f} km • ~{travel_time_minutes:.0f} min
|
| 320 |
</span>
|
| 321 |
</div>
|
gradio-ui/components/recommendations_display.py
CHANGED
|
@@ -40,7 +40,7 @@ def format_recommendations_display(recommendations) -> str:
|
|
| 40 |
|
| 41 |
html = """
|
| 42 |
<div style="padding: 20px;">
|
| 43 |
-
<h2 style="margin-top: 0; color: #
|
| 44 |
"""
|
| 45 |
|
| 46 |
# General Guidelines
|
|
@@ -128,10 +128,10 @@ def format_recommendations_display(recommendations) -> str:
|
|
| 128 |
# If no sections were rendered, show a debug view
|
| 129 |
if not has_content:
|
| 130 |
html += """
|
| 131 |
-
<div style="background:
|
| 132 |
-
<h3 style="color: #b45309; margin-top: 0;">⚠️ Raw Recommendations Data</h3>
|
| 133 |
-
<p style="color: #
|
| 134 |
-
<pre style="background:
|
| 135 |
"""
|
| 136 |
import json
|
| 137 |
try:
|
|
|
|
| 40 |
|
| 41 |
html = """
|
| 42 |
<div style="padding: 20px;">
|
| 43 |
+
<h2 style="margin-top: 0; color: #ffffff !important; font-weight: 700;">📋 Construction Recommendations</h2>
|
| 44 |
"""
|
| 45 |
|
| 46 |
# General Guidelines
|
|
|
|
| 128 |
# If no sections were rendered, show a debug view
|
| 129 |
if not has_content:
|
| 130 |
html += """
|
| 131 |
+
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid #d97706; border: 1px solid #fde68a;">
|
| 132 |
+
<h3 style="color: #b45309 !important; margin-top: 0;">⚠️ Raw Recommendations Data</h3>
|
| 133 |
+
<p style="color: #0f172a !important;">The recommendations data structure is unexpected. Here's the raw content:</p>
|
| 134 |
+
<pre style="background: #f8fafc; padding: 15px; border-radius: 4px; overflow-x: auto; color: #0f172a !important; font-size: 0.9em; border: 1px solid #e2e8f0;">
|
| 135 |
"""
|
| 136 |
import json
|
| 137 |
try:
|
gradio-ui/components/risk_display.py
CHANGED
|
@@ -65,7 +65,7 @@ def format_risk_display(risk_data) -> str:
|
|
| 65 |
# Build HTML output
|
| 66 |
html = f"""
|
| 67 |
<div style="padding: 20px;">
|
| 68 |
-
<h2 style="margin-top: 0; color: #
|
| 69 |
|
| 70 |
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid {risk_color}; box-shadow: 0 2px 4px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;">
|
| 71 |
<h3 style="color: {risk_color} !important; margin-top: 0; font-weight: 600;">Overall Risk Level: {risk_level}</h3>
|
|
@@ -166,10 +166,10 @@ def format_risk_display(risk_data) -> str:
|
|
| 166 |
cache_status = metadata.get('cache_status', 'Unknown') if isinstance(metadata, dict) else getattr(metadata, 'cache_status', 'Unknown')
|
| 167 |
|
| 168 |
html += f"""
|
| 169 |
-
<div style="background:
|
| 170 |
-
<p style="margin: 5px 0;"><strong>Data Source:</strong> {source}</p>
|
| 171 |
-
<p style="margin: 5px 0;"><strong>Last Updated:</strong> {timestamp}</p>
|
| 172 |
-
<p style="margin: 5px 0;"><strong>Cache Status:</strong> {cache_status}</p>
|
| 173 |
</div>
|
| 174 |
"""
|
| 175 |
|
|
|
|
| 65 |
# Build HTML output
|
| 66 |
html = f"""
|
| 67 |
<div style="padding: 20px;">
|
| 68 |
+
<h2 style="margin-top: 0; color: #ffffff !important; font-weight: 700;">🛡️ Risk Assessment Summary</h2>
|
| 69 |
|
| 70 |
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid {risk_color}; box-shadow: 0 2px 4px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;">
|
| 71 |
<h3 style="color: {risk_color} !important; margin-top: 0; font-weight: 600;">Overall Risk Level: {risk_level}</h3>
|
|
|
|
| 166 |
cache_status = metadata.get('cache_status', 'Unknown') if isinstance(metadata, dict) else getattr(metadata, 'cache_status', 'Unknown')
|
| 167 |
|
| 168 |
html += f"""
|
| 169 |
+
<div style="background: white; padding: 15px; border-radius: 8px; margin-top: 20px; font-size: 0.9em; border: 1px solid #e2e8f0;">
|
| 170 |
+
<p style="margin: 5px 0; color: #0f172a !important;"><strong style="color: #0f172a !important;">Data Source:</strong> {source}</p>
|
| 171 |
+
<p style="margin: 5px 0; color: #0f172a !important;"><strong style="color: #0f172a !important;">Last Updated:</strong> {timestamp}</p>
|
| 172 |
+
<p style="margin: 5px 0; color: #0f172a !important;"><strong style="color: #0f172a !important;">Cache Status:</strong> {cache_status}</p>
|
| 173 |
</div>
|
| 174 |
"""
|
| 175 |
|
gradio-ui/export_utils.py
CHANGED
|
@@ -204,7 +204,7 @@ def _generate_pdf_content(construction_plan: Any) -> str:
|
|
| 204 |
<div class="section">
|
| 205 |
<h2>Project Information</h2>
|
| 206 |
<p><strong>Building Type:</strong> {metadata.building_type.replace('_', ' ').title()}</p>
|
| 207 |
-
<p><strong>Location:</strong> {
|
| 208 |
<p><strong>Coordinates:</strong> {metadata.coordinates.latitude:.4f}°N, {metadata.coordinates.longitude:.4f}°E</p>
|
| 209 |
{f"<p><strong>Building Area:</strong> {metadata.building_area:.2f} sq meters</p>" if metadata.building_area else ""}
|
| 210 |
<p><strong>Generated:</strong> {metadata.generated_at}</p>
|
|
|
|
| 204 |
<div class="section">
|
| 205 |
<h2>Project Information</h2>
|
| 206 |
<p><strong>Building Type:</strong> {metadata.building_type.replace('_', ' ').title()}</p>
|
| 207 |
+
<p><strong>Location:</strong> {location.name}</p>
|
| 208 |
<p><strong>Coordinates:</strong> {metadata.coordinates.latitude:.4f}°N, {metadata.coordinates.longitude:.4f}°E</p>
|
| 209 |
{f"<p><strong>Building Area:</strong> {metadata.building_area:.2f} sq meters</p>" if metadata.building_area else ""}
|
| 210 |
<p><strong>Generated:</strong> {metadata.generated_at}</p>
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Disaster Risk Construction Planner - Hugging Face Deployment Requirements
|
| 2 |
+
|
| 3 |
+
# Gradio UI
|
| 4 |
+
gradio>=6.0.0
|
| 5 |
+
python-dotenv>=1.0.0
|
| 6 |
+
requests>=2.31.0
|
| 7 |
+
httpx>=0.27.0
|
| 8 |
+
weasyprint>=60.0 # For PDF export (optional)
|
| 9 |
+
|
| 10 |
+
# Data models and utilities
|
| 11 |
+
pydantic>=2.0.0
|