Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -94,8 +94,8 @@ def calculate_acreage_and_usable_land(intersections, merged_geometry):
|
|
94 |
|
95 |
# Step 9: Summarize Data using GPT-2
|
96 |
def summarize_flood_data_gpt2(flood_zone_areas, non_flooded_area, total_acreage):
|
97 |
-
# Use Hugging Face's hosted pipeline for
|
98 |
-
|
99 |
|
100 |
flood_prone_zones = ['A', 'AE', 'AH', 'AO', 'VE']
|
101 |
flood_zone_summary = "\n".join([f" Zone {zone}: {flood_zone_areas.get(zone, 0):.2f} acres" for zone in flood_prone_zones])
|
@@ -105,12 +105,14 @@ def summarize_flood_data_gpt2(flood_zone_areas, non_flooded_area, total_acreage)
|
|
105 |
**Usable Area**: {non_flooded_area:.2f} acres
|
106 |
**Flood-prone Zones**:
|
107 |
{flood_zone_summary}
|
108 |
-
Summarize the above given data in 2-3 sentences.
|
109 |
"""
|
110 |
|
111 |
-
response =
|
112 |
|
113 |
-
|
|
|
|
|
114 |
|
115 |
if uploaded_file is not None:
|
116 |
# Step 1: Read in the shapefiles
|
|
|
94 |
|
95 |
# Step 9: Summarize Data using GPT-2
|
96 |
def summarize_flood_data_gpt2(flood_zone_areas, non_flooded_area, total_acreage):
|
97 |
+
# Use Hugging Face's hosted pipeline for T5 small
|
98 |
+
summarizer = pipeline("summarization", model="t5-small")
|
99 |
|
100 |
flood_prone_zones = ['A', 'AE', 'AH', 'AO', 'VE']
|
101 |
flood_zone_summary = "\n".join([f" Zone {zone}: {flood_zone_areas.get(zone, 0):.2f} acres" for zone in flood_prone_zones])
|
|
|
105 |
**Usable Area**: {non_flooded_area:.2f} acres
|
106 |
**Flood-prone Zones**:
|
107 |
{flood_zone_summary}
|
108 |
+
Summarize the above given data in a 2-3 sentences.
|
109 |
"""
|
110 |
|
111 |
+
response = summarizer(prompt, max_length=200, min_length=30, do_sample=False)
|
112 |
|
113 |
+
# Use summary_text instead of generated_text for T5 model output
|
114 |
+
return response[0]['summary_text']
|
115 |
+
|
116 |
|
117 |
if uploaded_file is not None:
|
118 |
# Step 1: Read in the shapefiles
|