Spaces:
Running
Running
Update app.py
Browse files3 unmodified lines4567789101 unmodified line121314151617181915161718193 unmodified linesimport io
def remove_background(image): # Process image # Process image to bytes img_byte_arr = io.BytesIO() image.save(img_byte_arr, format='PNG') processed_bytes = rembg.remove(img_byte_arr.getvalue())1 unmodified line # Create PIL image for preview processed_img = Image.open(io.BytesIO(processed_bytes)) # Prepare download file download_bytes = io.BytesIO(processed_bytes) download_bytes.seek(0) # Reset buffer position return processed_img, download_bytes # Return (preview image, (filename, bytes)) for download return processed_img, ("no_background.png", processed_bytes)
# Gradio Interfaceimage_upload = gr.Image(label="Upload Image", type="pil")app.py+3-6