ritwikraha commited on
Commit
a30d4c8
·
verified ·
1 Parent(s): 7d1c6b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -2,13 +2,15 @@ import gradio as gr
2
  import cv2
3
 
4
  def create_mask(image):
5
- # Convert image to grayscale for easier segmentation
6
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
7
-
8
- # Apply thresholding to create a binary mask (adjust threshold value as needed)
9
- _, mask = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
10
-
11
- return mask
 
 
12
 
13
  with gr.Blocks() as demo:
14
  gr.Markdown(
 
2
  import cv2
3
 
4
  def create_mask(image):
5
+ image_array = gr.as_np_array(image)
6
+
7
+ # Convert image to grayscale for easier segmentation
8
+ gray = cv2.cvtColor(image_array, cv2.COLOR_BGR2GRAY)
9
+
10
+ # Apply thresholding to create a binary mask (adjust threshold value as needed)
11
+ _, mask = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
12
+
13
+ return mask
14
 
15
  with gr.Blocks() as demo:
16
  gr.Markdown(