Saad0KH commited on
Commit
a5e13bd
Β·
verified Β·
1 Parent(s): b3a76ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -73,15 +73,14 @@ def encode_image_to_base64(image):
73
  buffered = BytesIO()
74
  image.save(buffered, format="PNG") # Use PNG for compatibility with RGBA
75
  return base64.b64encode(buffered.getvalue()).decode('utf-8')
76
-
77
- # @spaces.GPU
78
  def rm_background(image):
79
  im = load_img(image, output_type="pil")
80
  im = im.convert("RGB")
81
  image_size = im.size
82
  origin = im.copy()
83
  image = load_img(im)
84
- input_images = transform_image(image).unsqueeze(0).to("cpu")
85
  # Prediction
86
  with torch.no_grad():
87
  preds = birefnet(input_images)[-1].sigmoid().cpu()
 
73
  buffered = BytesIO()
74
  image.save(buffered, format="PNG") # Use PNG for compatibility with RGBA
75
  return base64.b64encode(buffered.getvalue()).decode('utf-8')
76
+ @spaces.GPU
 
77
  def rm_background(image):
78
  im = load_img(image, output_type="pil")
79
  im = im.convert("RGB")
80
  image_size = im.size
81
  origin = im.copy()
82
  image = load_img(im)
83
+ input_images = transform_image(image).unsqueeze(0).to("cuda")
84
  # Prediction
85
  with torch.no_grad():
86
  preds = birefnet(input_images)[-1].sigmoid().cpu()