Spaces:
Running
on
Zero
Running
on
Zero
ZhengPeng7
commited on
Commit
•
eefba1b
1
Parent(s):
621c740
Add fast-foreground-estimation in masking image.
Browse files
app.py
CHANGED
@@ -141,12 +141,10 @@ def predict(images, resolution, weights_file):
|
|
141 |
image_proc = image_preprocessor.proc(image_pil)
|
142 |
image_proc = image_proc.unsqueeze(0)
|
143 |
|
144 |
-
#
|
145 |
with torch.no_grad():
|
146 |
-
|
147 |
-
|
148 |
-
if device == 'cuda':
|
149 |
-
scaled_pred_tensor = scaled_pred_tensor.cpu()
|
150 |
|
151 |
# Show Results
|
152 |
pred_pil = transforms.ToPILImage()(pred)
|
|
|
141 |
image_proc = image_preprocessor.proc(image_pil)
|
142 |
image_proc = image_proc.unsqueeze(0)
|
143 |
|
144 |
+
# Prediction
|
145 |
with torch.no_grad():
|
146 |
+
preds = birefnet(image_proc.to(device))[-1].sigmoid().cpu()
|
147 |
+
pred = preds[0].squeeze()
|
|
|
|
|
148 |
|
149 |
# Show Results
|
150 |
pred_pil = transforms.ToPILImage()(pred)
|