Spaces:
Running
Running
ritwikraha
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,15 @@ import gradio as gr
|
|
2 |
import cv2
|
3 |
|
4 |
def create_mask(image):
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
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(
|