Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
from PIL import Image
|
4 |
-
import numpy as np
|
5 |
|
6 |
-
|
7 |
-
pipe = pipeline("mask-generation", model="lightmedsam")
|
8 |
|
9 |
def predict(image_path):
|
10 |
# Perform image segmentation
|
@@ -18,22 +15,11 @@ def predict(image_path):
|
|
18 |
|
19 |
return segmented_image
|
20 |
|
21 |
-
|
22 |
-
# Assuming `mask` is a single-channel segmentation mask (grayscale)
|
23 |
-
# You may need to adjust this function based on the specifics of your model's output
|
24 |
-
|
25 |
-
# Convert single-channel mask to 3-channel (RGB) mask
|
26 |
-
colored_mask = np.zeros((*mask.shape, 3), dtype=np.uint8)
|
27 |
-
colored_mask[:, :, 0] = mask
|
28 |
-
colored_mask[:, :, 1] = mask
|
29 |
-
colored_mask[:, :, 2] = mask
|
30 |
-
|
31 |
-
return colored_mask
|
32 |
-
|
33 |
gr.Interface(
|
34 |
predict,
|
35 |
-
inputs=gr.Image(label="Upload
|
36 |
-
outputs=gr.
|
37 |
-
title="
|
38 |
allow_flagging="manual"
|
39 |
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
+
pipeline = pipeline(task="image-segmentation", model="Saim8250/litemedsam")
|
|
|
5 |
|
6 |
def predict(image_path):
|
7 |
# Perform image segmentation
|
|
|
15 |
|
16 |
return segmented_image
|
17 |
|
18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
gr.Interface(
|
20 |
predict,
|
21 |
+
inputs=gr.inputs.Image(label="Upload image", type="filepath"),
|
22 |
+
outputs=gr.outputs.Label(num_top_classes=2),
|
23 |
+
title="segmentation",
|
24 |
allow_flagging="manual"
|
25 |
).launch()
|