Spaces:
Running
Running
Update app.py
Browse files1234567899101112131011121314151617import gradio as grfrom PIL import Image, ImageChops, ImageFilterimport rembgimport ioimport tempfileimport osimport zipfile
def remove_background(image): """Remove background using rembg""" with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as temp: image.save(temp.name) result = rembg.remove(temp.name) return Image.open(result).convert("RGBA") """Remove background using rembg (fixed bytes handling)""" img_byte_arr = io.BytesIO() image.save(img_byte_arr, format='PNG') result_bytes = rembg.remove(img_byte_arr.getvalue()) # Process bytes directly return Image.open(io.BytesIO(result_bytes)).convert("RGBA")
def add_outline(image, outline_width=2, outline_color=(255, 255, 255)): """Add white outline to transparent image"""app.py+6-5