Spaces:
Running
on
Zero
Running
on
Zero
Update inference_seg.py
Browse files- inference_seg.py +9 -1
inference_seg.py
CHANGED
|
@@ -24,7 +24,15 @@ def load_model(use_box=False):
|
|
| 24 |
|
| 25 |
@torch.no_grad()
|
| 26 |
def run(model, img_path, box=None, device="cpu"):
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
mask = output
|
| 29 |
return mask
|
| 30 |
# import os
|
|
|
|
| 24 |
|
| 25 |
@torch.no_grad()
|
| 26 |
def run(model, img_path, box=None, device="cpu"):
|
| 27 |
+
model.move_to_device(device)
|
| 28 |
+
model.eval()
|
| 29 |
+
with torch.no_grad():
|
| 30 |
+
if box is not None:
|
| 31 |
+
use_box = True
|
| 32 |
+
else:
|
| 33 |
+
use_box = False
|
| 34 |
+
model.use_box = use_box
|
| 35 |
+
output = model(img_path, box=box)
|
| 36 |
mask = output
|
| 37 |
return mask
|
| 38 |
# import os
|