Spaces:
addsw11
/
Running on Zero

bgr / app.py
mrbeliever's picture
Update app.py
321c2b4 verified
raw
history blame
1.34 kB
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"),
live=True,
css="""
.gradio-container {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.gr-inputs, .gr-outputs {
display: flex;
flex-direction: column;
align-items: center;
}
.gr-button {
margin-top: 20px;
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
font-size: 16px;
border-radius: 5px;
transition: background-color 0.3s;
}
.gr-button:hover {
background-color: #45a049;
}
"""
)
if __name__ == "__main__":
iface.launch()