Spaces:
Running
Running
Update app.py
Browse files3 unmodified lines456778910111212131415161516171819203 unmodified linesimport io
def remove_background(image): # Process image to bytes # Convert image to bytes img_byte_arr = io.BytesIO() image.save(img_byte_arr, format='PNG') processed_bytes = rembg.remove(img_byte_arr.getvalue()) # Create PIL image for preview # Prepare outputs processed_img = Image.open(io.BytesIO(processed_bytes)) file_obj = io.BytesIO(processed_bytes) file_obj.name = "no_background.png" # Required for Gradio # Return (preview image, (filename, bytes)) for download return processed_img, ("no_background.png", processed_bytes) return processed_img, file_obj
# Gradio Interfaceimage_upload = gr.Image(label="Upload Image", type="pil")app.py+5-4