|
|
|
|
|
import pathlib |
|
|
|
import gradio as gr |
|
|
|
from model import run_model |
|
|
|
DESCRIPTION = '# [CutS3D](https://leonsick.github.io/cuts3d/): Cutting Semantics in 3D for 2D Unsupervised Instance Segmentation \n\n' \ |
|
'This is a demo for the CutS3D Zero-Shot model. The model is trained on ImageNet, initially with unsupervised pseudo-masks and then further with one round of self-training. The first prediction will likely be slow as the model is downloaded. Subsequent predictions will be faster. The template for this space was borrowed from the original CutLER space by [hysts](https://huggingface.co/hysts).' \ |
|
|
|
paths = sorted(pathlib.Path('demo_imgs').glob('*.jpg')) |
|
|
|
with gr.Blocks(css='style.css') as demo: |
|
gr.Markdown(DESCRIPTION) |
|
with gr.Row(): |
|
with gr.Column(): |
|
image = gr.Image(label='Input image', type='filepath') |
|
score_threshold = gr.Slider(label='Score threshold', |
|
minimum=0, |
|
maximum=1, |
|
value=0.45, |
|
step=0.05) |
|
run_button = gr.Button('Run') |
|
with gr.Column(): |
|
result = gr.Image(label='Result', type='numpy') |
|
with gr.Row(): |
|
gr.Examples(examples=[[path.as_posix()] for path in paths], |
|
inputs=image) |
|
|
|
run_button.click(fn=run_model, |
|
inputs=[ |
|
image, |
|
score_threshold, |
|
], |
|
outputs=result, |
|
api_name='run') |
|
demo.queue(max_size=60).launch(debug=True) |
|
|