Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -127,19 +127,19 @@ def create_reliable_map(df, location_col):
|
|
127 |
"""Create a map with multiple layer options and better error handling"""
|
128 |
|
129 |
# Set default tile
|
130 |
-
default_tile_name = "
|
131 |
|
132 |
# Initialize map
|
133 |
m = folium.Map(location=[20, 0], zoom_start=2, control_scale=True)
|
134 |
|
135 |
-
# Add all tile layers with the appropriate one active
|
136 |
for name, config in MAP_TILES.items():
|
137 |
folium.TileLayer(
|
138 |
tiles=config["url"],
|
139 |
attr=f"{config['attr']} ({name})",
|
140 |
name=name,
|
141 |
overlay=False,
|
142 |
-
control=
|
143 |
show=(name == default_tile_name) # Only show the default layer initially
|
144 |
).add_to(m)
|
145 |
|
@@ -202,8 +202,8 @@ def create_reliable_map(df, location_col):
|
|
202 |
coords.append(point)
|
203 |
processed_count += 1
|
204 |
|
205 |
-
# Layer control
|
206 |
-
folium.LayerControl(collapsed=False).add_to(m)
|
207 |
|
208 |
# Set bounds if we have coordinates
|
209 |
if coords:
|
@@ -540,74 +540,52 @@ with gr.Blocks(css=custom_css) as demo:
|
|
540 |
""")
|
541 |
|
542 |
with gr.Tabs():
|
543 |
-
with gr.TabItem("
|
544 |
gr.HTML("""
|
545 |
<div class="info-box">
|
546 |
-
<h3 style="margin-top: 0;">
|
547 |
-
<p>
|
548 |
</div>
|
549 |
""")
|
550 |
|
551 |
with gr.Row():
|
552 |
with gr.Column():
|
553 |
-
|
554 |
-
label="
|
555 |
-
|
556 |
-
|
|
|
557 |
)
|
558 |
-
|
559 |
-
label="
|
560 |
-
value="
|
561 |
-
|
|
|
562 |
)
|
563 |
-
|
564 |
-
|
565 |
-
gr.HTML("""
|
566 |
-
<div class="subtle-text">
|
567 |
-
<p><strong>Tips:</strong></p>
|
568 |
-
<ul>
|
569 |
-
<li>For best results, use specific location names (e.g., "Paris, France" instead of just "Paris")</li>
|
570 |
-
<li>You can switch between different map styles using the controls in the top-right</li>
|
571 |
-
<li>Click markers to see location details</li>
|
572 |
-
</ul>
|
573 |
-
</div>
|
574 |
-
""")
|
575 |
|
576 |
with gr.Column():
|
577 |
-
|
578 |
-
label="
|
579 |
-
value="""
|
580 |
-
<div style="text-align:center; height:70vh; display:flex; align-items:center; justify-content:center;
|
581 |
-
background-color:#f5f5f5; border:1px solid #e0e0e0; border-radius:8px;">
|
582 |
-
<div>
|
583 |
-
<img src="https://cdn-icons-png.flaticon.com/512/854/854878.png" width="100">
|
584 |
-
<p style="margin-top:20px; color:#666;">Your map will appear here after processing</p>
|
585 |
-
</div>
|
586 |
-
</div>
|
587 |
-
"""
|
588 |
-
)
|
589 |
-
stats_output = gr.Textbox(
|
590 |
-
label="Location Statistics",
|
591 |
-
lines=2,
|
592 |
elem_classes="stats-box"
|
593 |
)
|
594 |
-
|
595 |
-
label="
|
596 |
-
|
597 |
-
|
598 |
)
|
599 |
|
600 |
-
|
601 |
-
fn=
|
602 |
-
inputs=[
|
603 |
-
outputs=[
|
604 |
)
|
605 |
-
|
606 |
-
with gr.TabItem("
|
607 |
gr.HTML("""
|
608 |
<div class="info-box">
|
609 |
-
<h3 style="margin-top: 0;">
|
610 |
-
<p>
|
611 |
</div>
|
612 |
""")
|
613 |
|
|
|
127 |
"""Create a map with multiple layer options and better error handling"""
|
128 |
|
129 |
# Set default tile
|
130 |
+
default_tile_name = "Toner"
|
131 |
|
132 |
# Initialize map
|
133 |
m = folium.Map(location=[20, 0], zoom_start=2, control_scale=True)
|
134 |
|
135 |
+
# Add all tile layers with the appropriate one active, but no layer control
|
136 |
for name, config in MAP_TILES.items():
|
137 |
folium.TileLayer(
|
138 |
tiles=config["url"],
|
139 |
attr=f"{config['attr']} ({name})",
|
140 |
name=name,
|
141 |
overlay=False,
|
142 |
+
control=False, # Disable tile layer in controls
|
143 |
show=(name == default_tile_name) # Only show the default layer initially
|
144 |
).add_to(m)
|
145 |
|
|
|
202 |
coords.append(point)
|
203 |
processed_count += 1
|
204 |
|
205 |
+
# Layer control - removed as requested
|
206 |
+
# folium.LayerControl(collapsed=False).add_to(m)
|
207 |
|
208 |
# Set bounds if we have coordinates
|
209 |
if coords:
|
|
|
540 |
""")
|
541 |
|
542 |
with gr.Tabs():
|
543 |
+
with gr.TabItem("🔍 Text Extraction"):
|
544 |
gr.HTML("""
|
545 |
<div class="info-box">
|
546 |
+
<h3 style="margin-top: 0;">Extract Structured Data from Text</h3>
|
547 |
+
<p>Use NuExtract-1.5 to automatically extract structured information from historical texts. Define the JSON template for the data you want to extract.</p>
|
548 |
</div>
|
549 |
""")
|
550 |
|
551 |
with gr.Row():
|
552 |
with gr.Column():
|
553 |
+
template = gr.Textbox(
|
554 |
+
label="JSON Template",
|
555 |
+
value='{"earthquake location": "", "dateline location": ""}',
|
556 |
+
lines=5,
|
557 |
+
placeholder="Define the fields you want to extract as a JSON template"
|
558 |
)
|
559 |
+
text = gr.Textbox(
|
560 |
+
label="Text to Extract From",
|
561 |
+
value="Neues Erdbeben in Japan. Aus Tokio wird berichtet, daß in Yokohama bei einem Erdbeben sechs Personen getötet und 22 verwundet, in Tokio vier getötet und 22 verwundet wurden. In Yokohama seien 6VV Häuser zerstört worden. Die telephonische und telegraphische Verbindung zwischen Tokio und Osaka ist unterbrochen worden. Der Trambahnverkehr in Tokio liegt still. Auch der Eisenbahnverkehr zwischen Tokio und Yokohama ist unterbrochen. In Sngamo, einer Vorstadt von Tokio sind Brände ausgebrochen. Ein Eisenbahnzug stürzte in den Vajugawafluß zwischen Gotemba und Tokio. Sechs Züge wurden umgeworfen. Mit dem letzten japanischen Erdbeben sind seit eineinhalb Jahrtausenden bis heute in Japan 229 größere Erdbeben zu verzeichnen gewesen.",
|
562 |
+
lines=8,
|
563 |
+
placeholder="Enter the text you want to extract information from"
|
564 |
)
|
565 |
+
extract_btn = gr.Button("Extract Information", variant="primary", size="lg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
|
567 |
with gr.Column():
|
568 |
+
status = gr.Textbox(
|
569 |
+
label="Status",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
570 |
elem_classes="stats-box"
|
571 |
)
|
572 |
+
output = gr.Textbox(
|
573 |
+
label="Extracted Data",
|
574 |
+
elem_classes="stats-box",
|
575 |
+
lines=10
|
576 |
)
|
577 |
|
578 |
+
extract_btn.click(
|
579 |
+
fn=extract_info,
|
580 |
+
inputs=[template, text],
|
581 |
+
outputs=[status, output]
|
582 |
)
|
583 |
+
|
584 |
+
with gr.TabItem("📍 Location Mapping"):
|
585 |
gr.HTML("""
|
586 |
<div class="info-box">
|
587 |
+
<h3 style="margin-top: 0;">Map Your Historical Locations</h3>
|
588 |
+
<p>Upload an Excel file containing location data to create an interactive map visualization. The tool will geocode your locations and display them on a customizable map.</p>
|
589 |
</div>
|
590 |
""")
|
591 |
|