Spaces:
mashroo
/
Runtime error

YoussefAnso commited on
Commit
a3f04cd
·
1 Parent(s): 1e3c695

Add conversion of extracted image to PIL format in remove_background function in app.py. This ensures compatibility with subsequent image processing steps when the output is a NumPy array.

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -74,6 +74,9 @@ def remove_background(
74
  with tempfile.NamedTemporaryFile(suffix=".png", delete=True) as temp:
75
  image.save(temp.name)
76
  extracted_img, mask = dis_remove_background(DIS_ONNX_MODEL_PATH, temp.name)
 
 
 
77
  return extracted_img
78
 
79
  def do_resize_content(original_image: Image, scale_rate):
 
74
  with tempfile.NamedTemporaryFile(suffix=".png", delete=True) as temp:
75
  image.save(temp.name)
76
  extracted_img, mask = dis_remove_background(DIS_ONNX_MODEL_PATH, temp.name)
77
+ # Convert to PIL Image if needed
78
+ if isinstance(extracted_img, np.ndarray):
79
+ extracted_img = Image.fromarray(extracted_img)
80
  return extracted_img
81
 
82
  def do_resize_content(original_image: Image, scale_rate):