Spaces:
Running
Running
dev(naurgo): upgrade demo
Browse files- detection/booru_yolo.py +4 -2
- detection/censor.py +4 -2
- detection/eyes.py +2 -2
- detection/halfbody.py +2 -2
- detection/hand.py +2 -2
- detection/head.py +5 -26
- requirements.txt +1 -0
detection/booru_yolo.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
from typing import List, Tuple
|
2 |
|
3 |
from imgutils.data import ImageTyping
|
4 |
-
from imgutils.detect.booru_yolo import detect_with_booru_yolo,
|
|
|
5 |
|
6 |
from .base import DeepGHSObjectDetection
|
7 |
|
@@ -17,7 +18,8 @@ class BooruYOLODetection(DeepGHSObjectDetection):
|
|
17 |
return 0.7, 0.25
|
18 |
|
19 |
def _get_labels(self, model_name: str) -> List[str]:
|
20 |
-
|
|
|
21 |
|
22 |
def detect(self, image: ImageTyping, model_name: str,
|
23 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) -> \
|
|
|
1 |
from typing import List, Tuple
|
2 |
|
3 |
from imgutils.data import ImageTyping
|
4 |
+
from imgutils.detect.booru_yolo import detect_with_booru_yolo, _DEFAULT_MODEL
|
5 |
+
from imgutils.generic.yolo import _open_models_for_repo_id
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
|
|
18 |
return 0.7, 0.25
|
19 |
|
20 |
def _get_labels(self, model_name: str) -> List[str]:
|
21 |
+
_, _, labels = _open_models_for_repo_id(self._repo_id)._open_model(model_name)
|
22 |
+
return labels
|
23 |
|
24 |
def detect(self, image: ImageTyping, model_name: str,
|
25 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) -> \
|
detection/censor.py
CHANGED
@@ -2,7 +2,8 @@ import re
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
-
from imgutils.detect.censor import detect_censors
|
|
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
@@ -23,7 +24,8 @@ class CensorDetection(DeepGHSObjectDetection):
|
|
23 |
return 0.7, 0.3
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
-
|
|
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
+
from imgutils.detect.censor import detect_censors
|
6 |
+
from imgutils.generic.yolo import _open_models_for_repo_id
|
7 |
|
8 |
from .base import DeepGHSObjectDetection
|
9 |
|
|
|
24 |
return 0.7, 0.3
|
25 |
|
26 |
def _get_labels(self, model_name: str) -> List[str]:
|
27 |
+
_, _, labels = _open_models_for_repo_id(self._repo_id)._open_model(model_name)
|
28 |
+
return labels
|
29 |
|
30 |
def detect(self, image: ImageTyping, model_name: str,
|
31 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
detection/eyes.py
CHANGED
@@ -2,7 +2,7 @@ import re
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
-
from imgutils.detect.eye import detect_eyes
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
@@ -23,7 +23,7 @@ class EyesDetection(DeepGHSObjectDetection):
|
|
23 |
return 0.3, 0.3
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
-
return
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
+
from imgutils.detect.eye import detect_eyes
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
|
|
23 |
return 0.3, 0.3
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
+
return ['eye']
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
detection/halfbody.py
CHANGED
@@ -2,7 +2,7 @@ import re
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
-
from imgutils.detect.halfbody import detect_halfbody
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
@@ -23,7 +23,7 @@ class HalfBodyDetection(DeepGHSObjectDetection):
|
|
23 |
return 0.7, 0.5
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
-
return
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
+
from imgutils.detect.halfbody import detect_halfbody
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
|
|
23 |
return 0.7, 0.5
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
+
return ['halfbody']
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
detection/hand.py
CHANGED
@@ -2,7 +2,7 @@ import re
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
-
from imgutils.detect.hand import detect_hands
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
@@ -23,7 +23,7 @@ class HandDetection(DeepGHSObjectDetection):
|
|
23 |
return 0.7, 0.35
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
-
return
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
|
|
2 |
from typing import List, Tuple
|
3 |
|
4 |
from imgutils.data import ImageTyping
|
5 |
+
from imgutils.detect.hand import detect_hands
|
6 |
|
7 |
from .base import DeepGHSObjectDetection
|
8 |
|
|
|
23 |
return 0.7, 0.35
|
24 |
|
25 |
def _get_labels(self, model_name: str) -> List[str]:
|
26 |
+
return ['hand']
|
27 |
|
28 |
def detect(self, image: ImageTyping, model_name: str,
|
29 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) \
|
detection/head.py
CHANGED
@@ -1,37 +1,17 @@
|
|
1 |
-
import os.path
|
2 |
-
import re
|
3 |
from typing import List, Tuple
|
4 |
|
5 |
-
from hfutils.operate import get_hf_fs
|
6 |
-
from hfutils.utils import hf_fs_path, parse_hf_fs_path
|
7 |
from imgutils.data import ImageTyping
|
8 |
from imgutils.detect import detect_heads
|
9 |
|
10 |
-
from .base import
|
11 |
|
12 |
|
13 |
-
|
14 |
-
matching = re.fullmatch(r'^head_detect_best_(?P<level>[\s\S]+?)$', model_name)
|
15 |
-
return matching.group('level')
|
16 |
-
|
17 |
-
|
18 |
-
class HeadDetection(ObjectDetection):
|
19 |
def __init__(self):
|
20 |
-
self
|
21 |
|
22 |
def _get_default_model(self) -> str:
|
23 |
-
return '
|
24 |
-
|
25 |
-
def _list_models(self) -> List[str]:
|
26 |
-
hf_fs = get_hf_fs()
|
27 |
-
return [
|
28 |
-
os.path.splitext(os.path.basename(parse_hf_fs_path(path).filename))[0]
|
29 |
-
for path in hf_fs.glob(hf_fs_path(
|
30 |
-
repo_id=self.repo_id,
|
31 |
-
repo_type='model',
|
32 |
-
filename='head_detect/*.onnx',
|
33 |
-
))
|
34 |
-
]
|
35 |
|
36 |
def _get_default_iou_and_score(self, model_name: str) -> Tuple[float, float]:
|
37 |
return 0.7, 0.3
|
@@ -42,6 +22,5 @@ class HeadDetection(ObjectDetection):
|
|
42 |
def detect(self, image: ImageTyping, model_name: str,
|
43 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) -> \
|
44 |
List[Tuple[Tuple[float, float, float, float], str, float]]:
|
45 |
-
|
46 |
-
return detect_heads(image=image, level=level,
|
47 |
iou_threshold=iou_threshold, conf_threshold=score_threshold)
|
|
|
|
|
|
|
1 |
from typing import List, Tuple
|
2 |
|
|
|
|
|
3 |
from imgutils.data import ImageTyping
|
4 |
from imgutils.detect import detect_heads
|
5 |
|
6 |
+
from .base import DeepGHSObjectDetection
|
7 |
|
8 |
|
9 |
+
class HeadDetection(DeepGHSObjectDetection):
|
|
|
|
|
|
|
|
|
|
|
10 |
def __init__(self):
|
11 |
+
DeepGHSObjectDetection.__init__(self, repo_id='deepghs/anime_head_detection')
|
12 |
|
13 |
def _get_default_model(self) -> str:
|
14 |
+
return 'head_detect_v0.5_s_pruned'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def _get_default_iou_and_score(self, model_name: str) -> Tuple[float, float]:
|
17 |
return 0.7, 0.3
|
|
|
22 |
def detect(self, image: ImageTyping, model_name: str,
|
23 |
iou_threshold: float = 0.7, score_threshold: float = 0.25) -> \
|
24 |
List[Tuple[Tuple[float, float, float, float], str, float]]:
|
25 |
+
return detect_heads(image=image, model_name=model_name,
|
|
|
26 |
iou_threshold=iou_threshold, conf_threshold=score_threshold)
|
requirements.txt
CHANGED
@@ -8,4 +8,5 @@ pandas
|
|
8 |
opencv-python>=4.6.0
|
9 |
hbutils>=0.9.0
|
10 |
dghs-imgutils>=0.5.0
|
|
|
11 |
httpx
|
|
|
8 |
opencv-python>=4.6.0
|
9 |
hbutils>=0.9.0
|
10 |
dghs-imgutils>=0.5.0
|
11 |
+
git+https://github.com/deepghs/imgutils.git
|
12 |
httpx
|