switch to text field
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ from diffusers import FluxFillPipeline
|
|
8 |
from PIL import Image, ImageOps
|
9 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
10 |
import numpy as np
|
11 |
-
import matplotlib.pyplot as plt
|
12 |
|
13 |
torch.set_float32_matmul_precision(["high", "highest"][0])
|
14 |
|
@@ -125,6 +124,7 @@ def rmbg(image=None, url=None):
|
|
125 |
|
126 |
|
127 |
def mask_generation(image=None, d=None):
|
|
|
128 |
predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-tiny")
|
129 |
predictor.set_image(image)
|
130 |
input_point = np.array(d["input_points"])
|
@@ -220,14 +220,14 @@ sam2_tab = gr.Interface(
|
|
220 |
inputs=[
|
221 |
gr.Number(4, interactive=False),
|
222 |
gr.Image(type="pil"),
|
223 |
-
gr.
|
224 |
],
|
225 |
outputs=gr.Gallery(),
|
226 |
examples=[
|
227 |
[
|
228 |
4,
|
229 |
"./assets/truck.jpg",
|
230 |
-
{"input_points": [[500, 375], [1125, 625]], "input_labels": [1, 0]},
|
231 |
]
|
232 |
],
|
233 |
api_name="sam2",
|
|
|
8 |
from PIL import Image, ImageOps
|
9 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
10 |
import numpy as np
|
|
|
11 |
|
12 |
torch.set_float32_matmul_precision(["high", "highest"][0])
|
13 |
|
|
|
124 |
|
125 |
|
126 |
def mask_generation(image=None, d=None):
|
127 |
+
d = eval(d) # convert this to dictionary
|
128 |
predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-tiny")
|
129 |
predictor.set_image(image)
|
130 |
input_point = np.array(d["input_points"])
|
|
|
220 |
inputs=[
|
221 |
gr.Number(4, interactive=False),
|
222 |
gr.Image(type="pil"),
|
223 |
+
gr.Text(),
|
224 |
],
|
225 |
outputs=gr.Gallery(),
|
226 |
examples=[
|
227 |
[
|
228 |
4,
|
229 |
"./assets/truck.jpg",
|
230 |
+
'{"input_points": [[500, 375], [1125, 625]], "input_labels": [1, 0]}',
|
231 |
]
|
232 |
],
|
233 |
api_name="sam2",
|