Upload anime_object_detection/detection/nudenet.py with huggingface_hub
Browse files
anime_object_detection/detection/nudenet.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Tuple
|
| 2 |
+
|
| 3 |
+
from imgutils.data import ImageTyping
|
| 4 |
+
from imgutils.detect.nudenet import detect_with_nudenet, _LABELS
|
| 5 |
+
|
| 6 |
+
from .base import ObjectDetection
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class NudeNetDetection(ObjectDetection):
|
| 10 |
+
def _get_default_model(self) -> str:
|
| 11 |
+
return 'Default'
|
| 12 |
+
|
| 13 |
+
def _list_models(self) -> List[str]:
|
| 14 |
+
return ['Default']
|
| 15 |
+
|
| 16 |
+
def _get_default_iou_and_score(self, model_name: str) -> Tuple[float, float]:
|
| 17 |
+
return 0.45, 0.25
|
| 18 |
+
|
| 19 |
+
def _get_labels(self, model_name: str) -> List[str]:
|
| 20 |
+
return _LABELS
|
| 21 |
+
|
| 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_with_nudenet(image=image, iou_threshold=iou_threshold, score_threshold=score_threshold)
|