cr8 commited on
Commit
f5c101d
·
verified ·
1 Parent(s): 532cd7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -4,7 +4,7 @@ import rembg
4
  import io
5
 
6
  def remove_background(image):
7
- # Process image
8
  img_byte_arr = io.BytesIO()
9
  image.save(img_byte_arr, format='PNG')
10
  processed_bytes = rembg.remove(img_byte_arr.getvalue())
@@ -12,11 +12,8 @@ def remove_background(image):
12
  # Create PIL image for preview
13
  processed_img = Image.open(io.BytesIO(processed_bytes))
14
 
15
- # Prepare download file
16
- download_bytes = io.BytesIO(processed_bytes)
17
- download_bytes.seek(0) # Reset buffer position
18
-
19
- return processed_img, download_bytes
20
 
21
  # Gradio Interface
22
  image_upload = gr.Image(label="Upload Image", type="pil")
 
4
  import io
5
 
6
  def remove_background(image):
7
+ # Process image to bytes
8
  img_byte_arr = io.BytesIO()
9
  image.save(img_byte_arr, format='PNG')
10
  processed_bytes = rembg.remove(img_byte_arr.getvalue())
 
12
  # Create PIL image for preview
13
  processed_img = Image.open(io.BytesIO(processed_bytes))
14
 
15
+ # Return (preview image, (filename, bytes)) for download
16
+ return processed_img, ("no_background.png", processed_bytes)
 
 
 
17
 
18
  # Gradio Interface
19
  image_upload = gr.Image(label="Upload Image", type="pil")