itzjunayed commited on
Commit
2fca5ba
·
verified ·
1 Parent(s): 2028dcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -50,15 +50,20 @@ def predict_segmentation(image):
50
  # Create an alpha channel: 255 where there is segmentation, 0 otherwise
51
  rgba_img[:, :, 3] = np.where(predicted_img_resized > 0, 255, 0)
52
 
53
- # Convert the numpy array to an image and return it
54
  output_image = Image.fromarray(rgba_img)
55
- return output_image
 
 
 
 
 
56
 
57
  # Gradio Interface
58
  iface = gr.Interface(
59
  fn=predict_segmentation,
60
  inputs="image",
61
- outputs="image",
62
  live=False
63
  )
64
 
 
50
  # Create an alpha channel: 255 where there is segmentation, 0 otherwise
51
  rgba_img[:, :, 3] = np.where(predicted_img_resized > 0, 255, 0)
52
 
53
+ # Convert the numpy array to an image
54
  output_image = Image.fromarray(rgba_img)
55
+
56
+ # Save the image as PNG to return it
57
+ output_image_path = "/tmp/segmented_output.png"
58
+ output_image.save(output_image_path)
59
+
60
+ return output_image_path
61
 
62
  # Gradio Interface
63
  iface = gr.Interface(
64
  fn=predict_segmentation,
65
  inputs="image",
66
+ outputs="file", # Return the file path to download the PNG
67
  live=False
68
  )
69