Spaces:
Build error
Build error
Download app.py from srTeco/segmenta_image: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/spaces/srTeco/segmenta_image/resolve/main/app.py
- Command line
-
hf download hf://spaces/srTeco/segmenta_image/app.py
-
curl -L -o app.py https://huggingface.co/spaces/srTeco/segmenta_image/resolve/main/app.py
666 Bytes
| import gradio as gd | |
| from transformers import pipeline | |
| from PIL import Image | |
| def remove_bg(image): | |
| pipe = pipeline( | |
| "image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True | |
| ) | |
| pillow_mask = pipe(image, return_mask=True) # outputs a pillow mask | |
| pillow_image = pipe(image) | |
| return pillow_image | |
| # remove_bg("image\IMG_0637.jpg") | |
| app = gd.Interface( | |
| title="REMOVE BACKGROUND IMAGE", | |
| description="Faça upload da imagem para remover o bg", | |
| fn=remove_bg, | |
| inputs=gd.components.Image(type="pil"), | |
| outputs=gd.components.Image(type="pil", format="png"), | |
| ) | |
| if __name__ == "__main__": | |
| app.launch(share=True) | |