Abu1998 commited on
Commit
2cd83c7
1 Parent(s): 110c7d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -1,8 +1,14 @@
1
  import gradio as gr
 
 
2
  from depth_map_generator import generate_depth_map
3
  from depth_segmentation import segment_image_by_depth
4
 
5
  def on_process(image, num_segments):
 
 
 
 
6
  # Save the uploaded image
7
  original_img_path = "original.jpg"
8
  image.save(original_img_path)
@@ -27,7 +33,7 @@ with gr.Blocks() as demo:
27
  process_button = gr.Button("Process Image")
28
 
29
  with gr.Column():
30
- output_gallery = gr.Gallery(label="Segmented Images")
31
  download_button = gr.Files(label="Download All", file_count="multiple")
32
 
33
  process_button.click(on_process, [image_input, num_segments], [output_gallery, download_button])
 
1
  import gradio as gr
2
+ from PIL import Image as PILImage
3
+ import numpy as np
4
  from depth_map_generator import generate_depth_map
5
  from depth_segmentation import segment_image_by_depth
6
 
7
  def on_process(image, num_segments):
8
+ # Convert the NumPy array to a PIL Image
9
+ if isinstance(image, np.ndarray):
10
+ image = PILImage.fromarray(image)
11
+
12
  # Save the uploaded image
13
  original_img_path = "original.jpg"
14
  image.save(original_img_path)
 
33
  process_button = gr.Button("Process Image")
34
 
35
  with gr.Column():
36
+ output_gallery = gr.Gallery(label="Segmented Images").style(grid=[3, 2])
37
  download_button = gr.Files(label="Download All", file_count="multiple")
38
 
39
  process_button.click(on_process, [image_input, num_segments], [output_gallery, download_button])