Spaces:
Running
Running
Update
Browse files- .pre-commit-config.yaml +3 -12
- README.md +4 -1
- app.py +1 -6
- model.py +7 -10
- requirements.txt +1 -1
.pre-commit-config.yaml
CHANGED
@@ -21,26 +21,17 @@ repos:
|
|
21 |
- id: docformatter
|
22 |
args: ['--in-place']
|
23 |
- repo: https://github.com/pycqa/isort
|
24 |
-
rev: 5.
|
25 |
hooks:
|
26 |
- id: isort
|
27 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
28 |
-
rev: v0.
|
29 |
hooks:
|
30 |
- id: mypy
|
31 |
args: ['--ignore-missing-imports']
|
|
|
32 |
- repo: https://github.com/google/yapf
|
33 |
rev: v0.32.0
|
34 |
hooks:
|
35 |
- id: yapf
|
36 |
args: ['--parallel', '--in-place']
|
37 |
-
- repo: https://github.com/kynan/nbstripout
|
38 |
-
rev: 0.5.0
|
39 |
-
hooks:
|
40 |
-
- id: nbstripout
|
41 |
-
args: ['--extra-keys', 'metadata.interpreter metadata.kernelspec cell.metadata.pycharm']
|
42 |
-
- repo: https://github.com/nbQA-dev/nbQA
|
43 |
-
rev: 1.3.1
|
44 |
-
hooks:
|
45 |
-
- id: nbqa-isort
|
46 |
-
- id: nbqa-yapf
|
|
|
21 |
- id: docformatter
|
22 |
args: ['--in-place']
|
23 |
- repo: https://github.com/pycqa/isort
|
24 |
+
rev: 5.12.0
|
25 |
hooks:
|
26 |
- id: isort
|
27 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
28 |
+
rev: v0.991
|
29 |
hooks:
|
30 |
- id: mypy
|
31 |
args: ['--ignore-missing-imports']
|
32 |
+
additional_dependencies: ['types-python-slugify']
|
33 |
- repo: https://github.com/google/yapf
|
34 |
rev: v0.32.0
|
35 |
hooks:
|
36 |
- id: yapf
|
37 |
args: ['--parallel', '--in-place']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -4,9 +4,12 @@ emoji: π
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
|
|
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.35.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
suggested_hardware: t4-small
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
14 |
+
|
15 |
+
https://arxiv.org/abs/2204.12484
|
app.py
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
from __future__ import annotations
|
4 |
|
5 |
-
import argparse
|
6 |
import pathlib
|
7 |
import tarfile
|
8 |
|
@@ -13,10 +12,6 @@ from model import AppDetModel, AppPoseModel
|
|
13 |
DESCRIPTION = '# [ViTPose](https://github.com/ViTAE-Transformer/ViTPose)'
|
14 |
|
15 |
|
16 |
-
def set_example_image(example: list) -> dict:
|
17 |
-
return gr.Image.update(value=example[0])
|
18 |
-
|
19 |
-
|
20 |
def extract_tar() -> None:
|
21 |
if pathlib.Path('mmdet_configs/configs').exists():
|
22 |
return
|
@@ -160,4 +155,4 @@ with gr.Blocks(css='style.css') as demo:
|
|
160 |
],
|
161 |
outputs=pose_visualization)
|
162 |
|
163 |
-
demo.queue(
|
|
|
2 |
|
3 |
from __future__ import annotations
|
4 |
|
|
|
5 |
import pathlib
|
6 |
import tarfile
|
7 |
|
|
|
12 |
DESCRIPTION = '# [ViTPose](https://github.com/ViTAE-Transformer/ViTPose)'
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
15 |
def extract_tar() -> None:
|
16 |
if pathlib.Path('mmdet_configs/configs').exists():
|
17 |
return
|
|
|
155 |
],
|
156 |
outputs=pose_visualization)
|
157 |
|
158 |
+
demo.queue(max_size=10).launch()
|
model.py
CHANGED
@@ -14,7 +14,7 @@ if os.getenv('SYSTEM') == 'spaces':
|
|
14 |
|
15 |
subprocess.run(shlex.split('pip uninstall -y opencv-python'))
|
16 |
subprocess.run(shlex.split('pip uninstall -y opencv-python-headless'))
|
17 |
-
subprocess.run(shlex.split('pip install opencv-python-headless==4.
|
18 |
|
19 |
import huggingface_hub
|
20 |
import numpy as np
|
@@ -29,8 +29,6 @@ from mmdet.apis import inference_detector, init_detector
|
|
29 |
from mmpose.apis import (inference_top_down_pose_model, init_pose_model,
|
30 |
process_mmdet_results, vis_pose_result)
|
31 |
|
32 |
-
HF_TOKEN = os.getenv('HF_TOKEN')
|
33 |
-
|
34 |
|
35 |
class DetModel:
|
36 |
MODEL_DICT = {
|
@@ -72,8 +70,8 @@ class DetModel:
|
|
72 |
self._load_model(name)
|
73 |
|
74 |
def _load_model(self, name: str) -> nn.Module:
|
75 |
-
|
76 |
-
return init_detector(
|
77 |
|
78 |
def set_model(self, name: str) -> None:
|
79 |
if name == self.model_name:
|
@@ -152,11 +150,10 @@ class PoseModel:
|
|
152 |
self._load_model(name)
|
153 |
|
154 |
def _load_model(self, name: str) -> nn.Module:
|
155 |
-
|
156 |
-
ckpt_path = huggingface_hub.hf_hub_download('
|
157 |
-
|
158 |
-
|
159 |
-
model = init_pose_model(dic['config'], ckpt_path, device=self.device)
|
160 |
return model
|
161 |
|
162 |
def set_model(self, name: str) -> None:
|
|
|
14 |
|
15 |
subprocess.run(shlex.split('pip uninstall -y opencv-python'))
|
16 |
subprocess.run(shlex.split('pip uninstall -y opencv-python-headless'))
|
17 |
+
subprocess.run(shlex.split('pip install opencv-python-headless==4.8.0.74'))
|
18 |
|
19 |
import huggingface_hub
|
20 |
import numpy as np
|
|
|
29 |
from mmpose.apis import (inference_top_down_pose_model, init_pose_model,
|
30 |
process_mmdet_results, vis_pose_result)
|
31 |
|
|
|
|
|
32 |
|
33 |
class DetModel:
|
34 |
MODEL_DICT = {
|
|
|
70 |
self._load_model(name)
|
71 |
|
72 |
def _load_model(self, name: str) -> nn.Module:
|
73 |
+
d = self.MODEL_DICT[name]
|
74 |
+
return init_detector(d['config'], d['model'], device=self.device)
|
75 |
|
76 |
def set_model(self, name: str) -> None:
|
77 |
if name == self.model_name:
|
|
|
150 |
self._load_model(name)
|
151 |
|
152 |
def _load_model(self, name: str) -> nn.Module:
|
153 |
+
d = self.MODEL_DICT[name]
|
154 |
+
ckpt_path = huggingface_hub.hf_hub_download('public-data/ViTPose',
|
155 |
+
d['model'])
|
156 |
+
model = init_pose_model(d['config'], ckpt_path, device=self.device)
|
|
|
157 |
return model
|
158 |
|
159 |
def set_model(self, name: str) -> None:
|
requirements.txt
CHANGED
@@ -2,7 +2,7 @@ mmcv-full==1.5.0
|
|
2 |
mmdet==2.24.1
|
3 |
mmpose==0.25.1
|
4 |
numpy==1.23.5
|
5 |
-
opencv-python-headless==4.
|
6 |
openmim==0.1.5
|
7 |
timm==0.5.4
|
8 |
torch==1.11.0
|
|
|
2 |
mmdet==2.24.1
|
3 |
mmpose==0.25.1
|
4 |
numpy==1.23.5
|
5 |
+
opencv-python-headless==4.8.0.74
|
6 |
openmim==0.1.5
|
7 |
timm==0.5.4
|
8 |
torch==1.11.0
|