abhijeetsarkargis commited on
Commit
2290c65
·
1 Parent(s): 8243768

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,9 +1,14 @@
1
  import gradio as gr
2
  import rasterio
3
  import matplotlib.pyplot as plt
 
4
 
5
  # Function to visualize all bands of the TIFF image
6
  def visualize_bands(tiff_image):
 
 
 
 
7
  # Open the image file using rasterio
8
  with rasterio.open(tiff_image.name) as src:
9
  # Number of bands
@@ -30,7 +35,7 @@ def visualize_bands(tiff_image):
30
  # Define the Gradio interface
31
  iface = gr.Interface(
32
  fn=visualize_bands,
33
- inputs=gr.inputs.Image(type="file", label="Upload a TIFF image", accept=".tif"),
34
  outputs="auto",
35
  title="TIFF Image Bands Visualization",
36
  description="Upload a TIFF image and visualize all its bands.",
 
1
  import gradio as gr
2
  import rasterio
3
  import matplotlib.pyplot as plt
4
+ import os
5
 
6
  # Function to visualize all bands of the TIFF image
7
  def visualize_bands(tiff_image):
8
+ # Check if the file is a TIFF image
9
+ if not tiff_image.name.endswith('.tif'):
10
+ raise ValueError("Please upload a TIFF image file (.tif).")
11
+
12
  # Open the image file using rasterio
13
  with rasterio.open(tiff_image.name) as src:
14
  # Number of bands
 
35
  # Define the Gradio interface
36
  iface = gr.Interface(
37
  fn=visualize_bands,
38
+ inputs=gr.inputs.Image(type="file", label="Upload a TIFF image"),
39
  outputs="auto",
40
  title="TIFF Image Bands Visualization",
41
  description="Upload a TIFF image and visualize all its bands.",