Spaces:
Runtime error
Runtime error
Commit ·
55d6001
1
Parent(s): 168e9b5
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import rasterio
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
-
import io
|
| 5 |
|
| 6 |
def visualize_image(file_path):
|
| 7 |
# Read the 10-band image using rasterio
|
|
@@ -36,13 +35,13 @@ def visualize_image(file_path):
|
|
| 36 |
# Adjust the layout and display the visualization
|
| 37 |
plt.tight_layout()
|
| 38 |
|
| 39 |
-
# Save the figure to a
|
| 40 |
-
|
| 41 |
-
plt.savefig(
|
| 42 |
plt.close()
|
| 43 |
|
| 44 |
-
# Return the
|
| 45 |
-
return
|
| 46 |
|
| 47 |
# Interface for the Gradio app
|
| 48 |
iface = gr.Interface(
|
|
@@ -52,9 +51,9 @@ iface = gr.Interface(
|
|
| 52 |
live=True,
|
| 53 |
capture_session=True,
|
| 54 |
title="Earth Engine Image Segmentation",
|
| 55 |
-
description="Upload a TIFF image and
|
| 56 |
allow_download=True, # Enable download button for the output image
|
| 57 |
)
|
| 58 |
|
| 59 |
# Launch the Gradio app
|
| 60 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import rasterio
|
| 3 |
import matplotlib.pyplot as plt
|
|
|
|
| 4 |
|
| 5 |
def visualize_image(file_path):
|
| 6 |
# Read the 10-band image using rasterio
|
|
|
|
| 35 |
# Adjust the layout and display the visualization
|
| 36 |
plt.tight_layout()
|
| 37 |
|
| 38 |
+
# Save the figure to a temporary file and close it to release resources
|
| 39 |
+
temp_file = "/tmp/visualization.png"
|
| 40 |
+
plt.savefig(temp_file)
|
| 41 |
plt.close()
|
| 42 |
|
| 43 |
+
# Return the temporary file path, which will be used by Gradio to display the visualization
|
| 44 |
+
return temp_file
|
| 45 |
|
| 46 |
# Interface for the Gradio app
|
| 47 |
iface = gr.Interface(
|
|
|
|
| 51 |
live=True,
|
| 52 |
capture_session=True,
|
| 53 |
title="Earth Engine Image Segmentation",
|
| 54 |
+
description="Upload a TIFF image and segmentation all its bands.",
|
| 55 |
allow_download=True, # Enable download button for the output image
|
| 56 |
)
|
| 57 |
|
| 58 |
# Launch the Gradio app
|
| 59 |
+
iface.launch()
|