Thinkerbot/background-remover-pro
1
1import gradio as gr2from rembg import remove3from PIL import Image4 5def bg_remove(input_img):6 if input_img is None:7 return None8 img = Image.open(input_img)9 out = remove(img)10 return out11 12canva_css = """13<style>14 15body, .gradio-container {16 background: linear-gradient(135deg, #6EE7B7, #3B82F6, #9333EA);17 background-size: 300% 300%;18 animation: gradientFlow 12s ease infinite;19}20 21@keyframes gradientFlow {22 0% { background-position: 0% 50%; }23 50% { background-position: 100% 50%; }24 100% { background-position: 0% 50%; }25}26 27.card {28 backdrop-filter: blur(25px);29 background: rgba(255,255,255,0.25);30 border-radius: 22px;31 padding: 25px;32 box-shadow: 0 10px 35px rgba(0,0,0,0.2);33}34 35button {36 background: linear-gradient(90deg, #FF8A05, #FF4D00);37 border-radius: 14px !important;38 color: white !important;39 font-size: 18px !important;40 font-weight: bold;41 transition: 0.3s;42}43 44button:hover {45 transform: scale(1.05);46 box-shadow: 0 8px 20px rgba(255,76,0,0.4);47}48 49h1 {50 color: white !important;51 text-shadow: 0 4px 12px rgba(0,0,0,0.4);52 font-weight: 800;53}54 55</style>56"""57 58with gr.Blocks() as demo:59 gr.HTML(canva_css) 60 61 gr.HTML("<h1>✨ Canva Style Background Remover Pro</h1>")62 gr.HTML("<p style='color:white;font-size:20px;'>Upload an image and get a clean transparent background instantly!</p>")63 64 with gr.Row():65 with gr.Column(elem_id="upload-card"):66 inp = gr.Image(label="Upload Image", type="filepath")67 with gr.Column(elem_id="output-card"):68 out = gr.Image(label="Output")69 70 btn = gr.Button("Remove Background")71 btn.click(bg_remove, inp, out)72 73demo.launch()