Spaces:
Running
Running
Update app.py
Browse files3 unmodified lines456789101 unmodified line12131415161718192021223 unmodified linesimport iodef remove_background(image):# Process imageimg_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 previewprocessed_img = Image.open(io.BytesIO(processed_bytes))# Prepare download filedownload_bytes = io.BytesIO(processed_bytes)download_bytes.seek(0) # Reset buffer positionreturn processed_img, download_bytes# Gradio Interfaceimage_upload = gr.Image(label="Upload Image", type="pil")3 unmodified lines456789101 unmodified line12131415161718193 unmodified linesimport iodef remove_background(image):# Process image to bytesimg_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 previewprocessed_img = Image.open(io.BytesIO(processed_bytes))# Return (preview image, (filename, bytes)) for downloadreturn processed_img, ("no_background.png", processed_bytes)# Gradio Interfaceimage_upload = gr.Image(label="Upload Image", type="pil")
app.py+3-6