Spaces:
Runtime error
Runtime error
AAAAAAyq
commited on
Commit
·
ec68a7d
1
Parent(s):
dc120b2
Update app.py
Browse files
app.py
CHANGED
|
@@ -134,12 +134,12 @@ def fast_show_mask_gpu(annotation, ax,
|
|
| 134 |
|
| 135 |
# post_process(results[0].masks, Image.open("../data/cake.png"))
|
| 136 |
|
| 137 |
-
def predict(input, input_size=512,
|
| 138 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 139 |
input_size = int(input_size) # 确保 imgsz 是整数
|
| 140 |
results = model(input, device=device, retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
|
| 141 |
pil_image = fast_process(annotations=results[0].masks.data,
|
| 142 |
-
image=input, high_quality=
|
| 143 |
return pil_image
|
| 144 |
|
| 145 |
# input_size=1024
|
|
@@ -153,8 +153,8 @@ def predict(input, input_size=512, high_quality_visual=True):
|
|
| 153 |
# image=input, high_quality=high_quality_visual, device=device)
|
| 154 |
demo = gr.Interface(fn=predict,
|
| 155 |
inputs=[gr.components.Image(type='pil'),
|
| 156 |
-
gr.components.
|
| 157 |
-
gr.components.Checkbox(
|
| 158 |
outputs=['plot'],
|
| 159 |
# examples=[["assets/sa_8776.jpg", 1024, True]],
|
| 160 |
# ["assets/sa_1309.jpg", 1024]],
|
|
|
|
| 134 |
|
| 135 |
# post_process(results[0].masks, Image.open("../data/cake.png"))
|
| 136 |
|
| 137 |
+
def predict(input, input_size=512, high_visual_quality=True):
|
| 138 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 139 |
input_size = int(input_size) # 确保 imgsz 是整数
|
| 140 |
results = model(input, device=device, retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
|
| 141 |
pil_image = fast_process(annotations=results[0].masks.data,
|
| 142 |
+
image=input, high_quality=high_visual_quality, device=device)
|
| 143 |
return pil_image
|
| 144 |
|
| 145 |
# input_size=1024
|
|
|
|
| 153 |
# image=input, high_quality=high_quality_visual, device=device)
|
| 154 |
demo = gr.Interface(fn=predict,
|
| 155 |
inputs=[gr.components.Image(type='pil'),
|
| 156 |
+
gr.components.Slider(minimum=512, maximum=1024, value=1024, step=64),
|
| 157 |
+
gr.components.Checkbox(value=True)],
|
| 158 |
outputs=['plot'],
|
| 159 |
# examples=[["assets/sa_8776.jpg", 1024, True]],
|
| 160 |
# ["assets/sa_1309.jpg", 1024]],
|