oberbics commited on
Commit
71551a7
·
verified ·
1 Parent(s): 3de9a41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -55
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 = "Satellite"
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=True,
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("📍 Location Mapping"):
544
  gr.HTML("""
545
  <div class="info-box">
546
- <h3 style="margin-top: 0;">Map Your Historical Locations</h3>
547
- <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>
548
  </div>
549
  """)
550
 
551
  with gr.Row():
552
  with gr.Column():
553
- excel_file = gr.File(
554
- label="Upload Excel File",
555
- file_types=[".xlsx", ".xls"],
556
- elem_classes="file-upload-box"
 
557
  )
558
- places_column = gr.Textbox(
559
- label="Location Column Name",
560
- value="dateline_locations",
561
- placeholder="e.g., 'location', 'city', or 'address'"
 
562
  )
563
- process_btn = gr.Button("Generate Map", variant="primary", size="lg")
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
- map_output = gr.HTML(
578
- label="Interactive Map",
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
- processed_file = gr.File(
595
- label="Download Processed Data",
596
- visible=True,
597
- interactive=False
598
  )
599
 
600
- process_btn.click(
601
- fn=process_and_map,
602
- inputs=[excel_file, places_column],
603
- outputs=[map_output, stats_output, processed_file]
604
  )
605
-
606
- with gr.TabItem("🔍 Text Extraction"):
607
  gr.HTML("""
608
  <div class="info-box">
609
- <h3 style="margin-top: 0;">Extract Structured Data from Text</h3>
610
- <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>
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