Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ SAR_SHAPE = (HEIGHT, WIDTH, 1)
|
|
| 23 |
OPTIC_SHAPE = (HEIGHT, WIDTH, 3)
|
| 24 |
MASK_SHAPE = (HEIGHT, WIDTH, 4) # One-hot encoded masks with 4 classes
|
| 25 |
|
| 26 |
-
# Class colors: non-mining (green),
|
| 27 |
CLASS_COLORS = [
|
| 28 |
[115/255, 178/255, 115/255],
|
| 29 |
[1, 0, 0],
|
|
@@ -349,23 +349,23 @@ if st.button("Run Inference"):
|
|
| 349 |
transform, crs = get_transform_from_tif(optic_path)
|
| 350 |
|
| 351 |
# Convert mask to mining polygons
|
|
|
|
| 352 |
mining_gdf = mask_to_polygons(pred_label_mask, transform, mining_class_id=1)
|
|
|
|
| 353 |
|
| 354 |
# Make sure WIUP and prediction are in same CRS
|
| 355 |
wiup_gdf = wiup_gdf.to_crs(mining_gdf.crs)
|
| 356 |
|
| 357 |
-
# Find area
|
| 358 |
-
|
|
|
|
|
|
|
| 359 |
|
| 360 |
# Display in Streamlit
|
| 361 |
-
st.success(f"
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
geojson = illegal_area_gdf.to_crs(epsg=4326).to_json()
|
| 367 |
-
st.download_button("Download GeoJSON", geojson, file_name="illegal_area.geojson", mime="application/json")
|
| 368 |
-
|
| 369 |
|
| 370 |
else:
|
| 371 |
st.warning("Please upload all three .tiff files to proceed.")
|
|
|
|
| 23 |
OPTIC_SHAPE = (HEIGHT, WIDTH, 3)
|
| 24 |
MASK_SHAPE = (HEIGHT, WIDTH, 4) # One-hot encoded masks with 4 classes
|
| 25 |
|
| 26 |
+
# Class colors: non-mining (green), mining (red), beach (black)
|
| 27 |
CLASS_COLORS = [
|
| 28 |
[115/255, 178/255, 115/255],
|
| 29 |
[1, 0, 0],
|
|
|
|
| 349 |
transform, crs = get_transform_from_tif(optic_path)
|
| 350 |
|
| 351 |
# Convert mask to mining polygons
|
| 352 |
+
non_mining_gdf = mask_to_polygons(pred_label_mask, transform, mining_class_id=0)
|
| 353 |
mining_gdf = mask_to_polygons(pred_label_mask, transform, mining_class_id=1)
|
| 354 |
+
beach_gdf = mask_to_polygons(pred_label_mask, transform, mining_class_id=2)
|
| 355 |
|
| 356 |
# Make sure WIUP and prediction are in same CRS
|
| 357 |
wiup_gdf = wiup_gdf.to_crs(mining_gdf.crs)
|
| 358 |
|
| 359 |
+
# Find area
|
| 360 |
+
non_mining_area, non_mining_area_gdf = calculate_illegal_area(non_mining_gdf, wiup_gdf)
|
| 361 |
+
mining_area, mining_area_gdf = calculate_illegal_area(mining_gdf, wiup_gdf)
|
| 362 |
+
beach_area, beach_area_gdf = calculate_illegal_area(beach_gdf, wiup_gdf)
|
| 363 |
|
| 364 |
# Display in Streamlit
|
| 365 |
+
st.success(f" Non Mining Area : {non_mining_area/1e6:.2f} sq. km")
|
| 366 |
+
st.success(f" Mining Area : {mining_area/1e6:.2f} sq. km")
|
| 367 |
+
st.success(f" Beach Area : {beach_area/1e6:.2f} sq. km")
|
| 368 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
else:
|
| 371 |
st.warning("Please upload all three .tiff files to proceed.")
|