Update
Browse files- .pre-commit-config.yaml +1 -1
- README.md +2 -1
- app.py +33 -22
- requirements.txt +3 -3
- style.css +3 -0
.pre-commit-config.yaml
CHANGED
|
@@ -20,7 +20,7 @@ repos:
|
|
| 20 |
- id: docformatter
|
| 21 |
args: ['--in-place']
|
| 22 |
- repo: https://github.com/pycqa/isort
|
| 23 |
-
rev: 5.
|
| 24 |
hooks:
|
| 25 |
- id: isort
|
| 26 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
|
|
| 20 |
- id: docformatter
|
| 21 |
args: ['--in-place']
|
| 22 |
- repo: https://github.com/pycqa/isort
|
| 23 |
+
rev: 5.12.0
|
| 24 |
hooks:
|
| 25 |
- id: isort
|
| 26 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
README.md
CHANGED
|
@@ -4,10 +4,11 @@ emoji: 🌍
|
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.36.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
suggested_hardware: t4-small
|
| 12 |
---
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
|
|
|
|
| 3 |
import pathlib
|
| 4 |
|
| 5 |
import gradio as gr
|
|
@@ -19,27 +20,37 @@ def run(image_path, threshold, max_num_mask):
|
|
| 19 |
return image
|
| 20 |
|
| 21 |
|
| 22 |
-
|
| 23 |
-
DESCRIPTION = 'This is an unofficial demo for https://github.com/facebookresearch/CutLER.'
|
| 24 |
|
| 25 |
paths = sorted(pathlib.Path('CutLER/maskcut/imgs').glob('*.jpg'))
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
gr.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
|
| 3 |
+
import os
|
| 4 |
import pathlib
|
| 5 |
|
| 6 |
import gradio as gr
|
|
|
|
| 20 |
return image
|
| 21 |
|
| 22 |
|
| 23 |
+
DESCRIPTION = '# [MaskCut](https://github.com/facebookresearch/CutLER)'
|
|
|
|
| 24 |
|
| 25 |
paths = sorted(pathlib.Path('CutLER/maskcut/imgs').glob('*.jpg'))
|
| 26 |
+
|
| 27 |
+
with gr.Blocks(css='style.css') as demo:
|
| 28 |
+
gr.Markdown(DESCRIPTION)
|
| 29 |
+
with gr.Row():
|
| 30 |
+
with gr.Column():
|
| 31 |
+
image = gr.Image(label='Input image', type='filepath')
|
| 32 |
+
threshold = gr.Slider(
|
| 33 |
+
label='Threshold used for producing binary graph',
|
| 34 |
+
minimum=0,
|
| 35 |
+
maximum=1,
|
| 36 |
+
step=0.01,
|
| 37 |
+
value=0.15)
|
| 38 |
+
max_masks = gr.Slider(
|
| 39 |
+
label='The maximum number of pseudo-masks per image',
|
| 40 |
+
minimum=1,
|
| 41 |
+
maximum=20,
|
| 42 |
+
step=1,
|
| 43 |
+
value=6)
|
| 44 |
+
run_button = gr.Button('Run')
|
| 45 |
+
with gr.Column():
|
| 46 |
+
result = gr.Image(label='Result')
|
| 47 |
+
|
| 48 |
+
inputs = [image, threshold, max_masks]
|
| 49 |
+
gr.Examples(examples=[[path.as_posix(), 0.15, 6] for path in paths],
|
| 50 |
+
inputs=inputs,
|
| 51 |
+
outputs=result,
|
| 52 |
+
fn=run,
|
| 53 |
+
cache_examples=os.getenv('CACHE_EXAMPLES') == '1')
|
| 54 |
+
|
| 55 |
+
run_button.click(fn=run, inputs=inputs, outputs=result, api_name='run')
|
| 56 |
+
demo.queue(max_size=20).launch()
|
requirements.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
git+https://github.com/lucasb-eyer/pydensecrf@0d53acb
|
| 2 |
-
gradio==3.
|
| 3 |
numpy==1.23.5
|
| 4 |
-
opencv-python==4.
|
| 5 |
pycocotools==2.0.6
|
| 6 |
scikit-image==0.19.2
|
| 7 |
torch==1.13.1
|
| 8 |
torchvision==0.14.1
|
| 9 |
-
tqdm==4.
|
|
|
|
| 1 |
git+https://github.com/lucasb-eyer/pydensecrf@0d53acb
|
| 2 |
+
gradio==3.36.1
|
| 3 |
numpy==1.23.5
|
| 4 |
+
opencv-python==4.8.0.74
|
| 5 |
pycocotools==2.0.6
|
| 6 |
scikit-image==0.19.2
|
| 7 |
torch==1.13.1
|
| 8 |
torchvision==0.14.1
|
| 9 |
+
tqdm==4.65.0
|
style.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
h1 {
|
| 2 |
+
text-align: center;
|
| 3 |
+
}
|