Spaces:
Sleeping
Sleeping
File size: 2,491 Bytes
c4b3a12 2c9a089 1138828 2c9a089 1138828 2c9a089 f94eae5 2c9a089 badd5ba f847fa1 f94eae5 f847fa1 f94eae5 f847fa1 f94eae5 f847fa1 f94eae5 f847fa1 f94eae5 40a42ca 2c9a089 1138828 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
import spaces
import gradio as gr
from transparent_background import Remover
from PIL import Image
import numpy as np
@spaces.GPU
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
# Gradio Interface
iface = gr.Interface(
fn=remove_background,
inputs=gr.Image(label="Upload Image"),
outputs=gr.Image(label="Output Image"),
css="""
body {
font-family: 'Arial', sans-serif;
background-color: #1a1a2e;
color: #ffffff;
}
.gradio-container {
background-color: #1a1a2e;
color: #ffffff;
}
.gr-button {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
}
.gr-button:hover {
background-color: #45a049;
}
.gr-input, .gr-output {
background-color: #2a2a3e;
color: #ffffff;
border: 1px solid #4a4a5e;
display: block;
margin: 0 auto;
}
.gr-input img {
width: 30px;
height: 30px;
object-fit: contain;
}
.gr-output img {
max-width: 300px;
max-height: 300px;
object-fit: contain;
display: block;
margin: 0 auto;
}
.gr-input:focus, .gr-output:focus {
outline: none;
border-color: #6a6a7e;
}
.gr-file-upload {
background-color: #2a2a3e;
color: #ffffff;
}
.gr-slider {
background-color: #2a2a3e;
color: #ffffff;
}
.gr-dropdown {
background-color: #2a2a3e;
color: #ffffff;
}
.gr-image-preview {
border: 2px solid #4a4a5e;
background-color: #2a2a3e;
}
.gr-textbox {
background-color: #2a2a3e;
color: #ffffff;
border: 1px solid #4a4a5e;
}
.gr-textbox:focus {
outline: none;
border-color: #6a6a7e;
}
""",
title="",
description=""
)
if __name__ == "__main__":
iface.launch()
|