Download app.py from addsw11/bgr: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/spaces/addsw11/bgr/resolve/main/app.py
- Command line
-
hf download hf://spaces/addsw11/bgr/app.py
-
curl -L -o app.py https://huggingface.co/spaces/addsw11/bgr/resolve/main/app.py
666 Bytes
| import spaces | |
| import gradio as gr | |
| from transparent_background import Remover | |
| from PIL import Image | |
| import numpy as np | |
| def remove_background(image): | |
| remover = Remover() | |
| if isinstance(image, Image.Image): | |
| output = remover.process(image) | |
| elif isinstance(image, np.ndarray): | |
| image_pil = Image.fromarray(image) | |
| output = remover.process(image_pil) | |
| else: | |
| raise TypeError("Unsupported image type") | |
| return output | |
| iface = gr.Interface( | |
| fn=remove_background, | |
| inputs=gr.Image(label="Upload Image"), | |
| outputs=gr.Image(label="Output Image") | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |