ZhengPeng7 commited on
Commit
eefba1b
1 Parent(s): 621c740

Add fast-foreground-estimation in masking image.

Browse files
Files changed (1) hide show
  1. app.py +3 -5
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
- # Perform the prediction
145
  with torch.no_grad():
146
- scaled_pred_tensor = birefnet(image_proc.to(device))[-1].sigmoid()
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)