Loading docs/source/api_doc/detect/halfbody.rst +2 −2 Original line number Diff line number Diff line Loading @@ -6,9 +6,9 @@ imgutils.detect.halfbody .. automodule:: imgutils.detect.halfbody detect_halfbodies detect_halfbody ------------------------------ .. autofunction:: detect_halfbodies .. autofunction:: detect_halfbody docs/source/api_doc/detect/halfbody_detect_benchmark.plot.py +2 −2 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot_cli from imgutils.detect import detect_halfbodies from imgutils.detect import detect_halfbody class HalfBodyDetectBenchmark(BaseBenchmark): Loading @@ -20,7 +20,7 @@ class HalfBodyDetectBenchmark(BaseBenchmark): def run(self): image_file = random.choice(self.all_images) _ = detect_halfbodies(image_file, level=self.level, version=self.version) _ = detect_halfbody(image_file, level=self.level, version=self.version) if __name__ == '__main__': Loading docs/source/api_doc/detect/halfbody_detect_demo.plot.py +2 −2 Original line number Diff line number Diff line from imgutils.detect import detect_halfbodies from imgutils.detect import detect_halfbody from imgutils.detect.halfbody import _LABELS from imgutils.detect.visual import detection_visualize from plot import image_plot def _detect(img, **kwargs): return detection_visualize(img, detect_halfbodies(img, **kwargs), _LABELS) return detection_visualize(img, detect_halfbody(img, **kwargs), _LABELS) if __name__ == '__main__': Loading imgutils/detect/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ Overview: """ from .censor import detect_censors from .face import detect_faces from .halfbody import detect_halfbodies from .halfbody import detect_halfbody from .hand import detect_hands from .head import detect_heads from .person import detect_person Loading imgutils/detect/halfbody.py +13 −6 Original line number Diff line number Diff line """ Overview: Detect human halfbody points (including female's nipples and genitals of both male and female) in anime images. Detect upper-half body in anime images. Trained on dataset `deepghs/anime_halfbody_detection <https://huggingface.co/datasets/deepghs/anime_halfbody_detection>`_ with YOLOv8. Loading @@ -12,6 +12,13 @@ Overview: .. image:: halfbody_detect_benchmark.plot.py.svg :align: center .. warning:: Please note that the primary purpose of this tool is to crop upper-body images from illustrations. Therefore, the training data used mostly consists of single-person images, and the performance on images with multiple people is not guaranteed. **If you indeed need to process images with multiple people, the recommended approach is to first use the :func:`imgutils.detect.detect_person` function to crop individuals, and then use this tool to obtain upper-body images**. """ from functools import lru_cache from typing import List, Tuple Loading @@ -34,12 +41,12 @@ def _open_halfbody_detect_model(level: str = 's', version: str = 'v1.0'): _LABELS = ["halfbody"] def detect_halfbodies(image: ImageTyping, level: str = 's', version: str = 'v0.4', max_infer_size=640, def detect_halfbody(image: ImageTyping, level: str = 's', version: str = 'v0.4', max_infer_size=640, conf_threshold: float = 0.5, iou_threshold: float = 0.7) \ -> List[Tuple[Tuple[int, int, int, int], str, float]]: """ Overview: Detect human halfbodies in anime images. Detect human upper-half body in anime images. :param image: Image to detect. :param level: The model level being used can be either `s` or `n`. Loading @@ -56,10 +63,10 @@ def detect_halfbodies(image: ImageTyping, level: str = 's', version: str = 'v0.4 the target type (always `halfbody`) and the target confidence score. Examples:: >>> from imgutils.detect import detect_halfbodies, detection_visualize >>> from imgutils.detect import detect_halfbody, detection_visualize >>> >>> image = 'nude_girl.png' >>> result = detect_halfbodies(image) # detect it >>> result = detect_halfbody(image) # detect it >>> result [ ((365, 264, 399, 289), 'nipple_f', 0.7473511695861816), Loading Loading
docs/source/api_doc/detect/halfbody.rst +2 −2 Original line number Diff line number Diff line Loading @@ -6,9 +6,9 @@ imgutils.detect.halfbody .. automodule:: imgutils.detect.halfbody detect_halfbodies detect_halfbody ------------------------------ .. autofunction:: detect_halfbodies .. autofunction:: detect_halfbody
docs/source/api_doc/detect/halfbody_detect_benchmark.plot.py +2 −2 Original line number Diff line number Diff line import random from benchmark import BaseBenchmark, create_plot_cli from imgutils.detect import detect_halfbodies from imgutils.detect import detect_halfbody class HalfBodyDetectBenchmark(BaseBenchmark): Loading @@ -20,7 +20,7 @@ class HalfBodyDetectBenchmark(BaseBenchmark): def run(self): image_file = random.choice(self.all_images) _ = detect_halfbodies(image_file, level=self.level, version=self.version) _ = detect_halfbody(image_file, level=self.level, version=self.version) if __name__ == '__main__': Loading
docs/source/api_doc/detect/halfbody_detect_demo.plot.py +2 −2 Original line number Diff line number Diff line from imgutils.detect import detect_halfbodies from imgutils.detect import detect_halfbody from imgutils.detect.halfbody import _LABELS from imgutils.detect.visual import detection_visualize from plot import image_plot def _detect(img, **kwargs): return detection_visualize(img, detect_halfbodies(img, **kwargs), _LABELS) return detection_visualize(img, detect_halfbody(img, **kwargs), _LABELS) if __name__ == '__main__': Loading
imgutils/detect/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ Overview: """ from .censor import detect_censors from .face import detect_faces from .halfbody import detect_halfbodies from .halfbody import detect_halfbody from .hand import detect_hands from .head import detect_heads from .person import detect_person Loading
imgutils/detect/halfbody.py +13 −6 Original line number Diff line number Diff line """ Overview: Detect human halfbody points (including female's nipples and genitals of both male and female) in anime images. Detect upper-half body in anime images. Trained on dataset `deepghs/anime_halfbody_detection <https://huggingface.co/datasets/deepghs/anime_halfbody_detection>`_ with YOLOv8. Loading @@ -12,6 +12,13 @@ Overview: .. image:: halfbody_detect_benchmark.plot.py.svg :align: center .. warning:: Please note that the primary purpose of this tool is to crop upper-body images from illustrations. Therefore, the training data used mostly consists of single-person images, and the performance on images with multiple people is not guaranteed. **If you indeed need to process images with multiple people, the recommended approach is to first use the :func:`imgutils.detect.detect_person` function to crop individuals, and then use this tool to obtain upper-body images**. """ from functools import lru_cache from typing import List, Tuple Loading @@ -34,12 +41,12 @@ def _open_halfbody_detect_model(level: str = 's', version: str = 'v1.0'): _LABELS = ["halfbody"] def detect_halfbodies(image: ImageTyping, level: str = 's', version: str = 'v0.4', max_infer_size=640, def detect_halfbody(image: ImageTyping, level: str = 's', version: str = 'v0.4', max_infer_size=640, conf_threshold: float = 0.5, iou_threshold: float = 0.7) \ -> List[Tuple[Tuple[int, int, int, int], str, float]]: """ Overview: Detect human halfbodies in anime images. Detect human upper-half body in anime images. :param image: Image to detect. :param level: The model level being used can be either `s` or `n`. Loading @@ -56,10 +63,10 @@ def detect_halfbodies(image: ImageTyping, level: str = 's', version: str = 'v0.4 the target type (always `halfbody`) and the target confidence score. Examples:: >>> from imgutils.detect import detect_halfbodies, detection_visualize >>> from imgutils.detect import detect_halfbody, detection_visualize >>> >>> image = 'nude_girl.png' >>> result = detect_halfbodies(image) # detect it >>> result = detect_halfbody(image) # detect it >>> result [ ((365, 264, 399, 289), 'nipple_f', 0.7473511695861816), Loading