sanghyun-lee
create remover only once
32644bf
raw
history blame contribute delete
590 Bytes
import gradio as gr
from transparent_background import Remover
remover = Remover(mode='base-nightly')
def run(inp_image, sod_type):
return remover.process(inp_image.convert("RGB"), type=sod_type)
with gr.Blocks() as demo:
with gr.Row():
inp_image = gr.Image(type="pil")
res_image = gr.Image(type="pil")
sod_type = gr.Radio(["rgba", "map", "green", "white", "blur", "overlay"], value="rgba")
submit_btn = gr.Button(value="Submit")
submit_btn.click(run, inputs=[inp_image, sod_type], outputs=[res_image])
if __name__ == "__main__":
demo.launch()