import shutil
import gradio as gr
from PIL import Image
import sys, os
from rembg import remove
def run_rembg(img):
output = remove(img)
return output
if __name__=="__main__":
with gr.Blocks() as demo:
gr.Markdown(
"""
Image Matting using U2-Net
"""
)
with gr.Row():
with gr.Column():
gr.Markdown(
"""
Input Image
"""
)
image_input = gr.Image(type="numpy", label=" ")
with gr.Column():
gr.Markdown(
"""
Output Image
"""
)
image_output = gr.Image(type="numpy", label=" ")
btn = gr.Button("Run!")
btn.click(
fn=run_rembg,
inputs=image_input,
outputs=image_output,
api_name="imageMatting"
)
gr.Markdown(
"""
---
Acknowledgments
- Library
- Library Git hub : [danielgatis/rembg](https://github.com/danielgatis/rembg)
- Cloned on 2023/3/12
- Algorithm
- Library Git hub : [U2-Net](https://github.com/xuebinqin/U-2-Net)
"""
)
demo.launch(
favicon_path="./assets/ハサミのフリーアイコン.png"
)