Unverified Commit 4bc8d188 authored by narugo1992's avatar narugo1992 Committed by GitHub
Browse files

Merge pull request #104 from deepghs/dev/nudenet

dev(narugo): add nudenet
parents 558e96d9 3fca6cf6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ imgutils.detect
    halfbody
    hand
    head
    nudenet
    person
    text
    visual
+14 −0
Original line number Diff line number Diff line
imgutils.detect.nudenet
==========================

.. currentmodule:: imgutils.detect.nudenet

.. automodule:: imgutils.detect.nudenet


detect_with_nudenet
------------------------------

.. autofunction:: detect_with_nudenet

+34 −0
Original line number Diff line number Diff line
import random

from benchmark import BaseBenchmark, create_plot_cli
from imgutils.detect import detect_with_nudenet


class NudenetDetectBenchmark(BaseBenchmark):
    def __init__(self):
        BaseBenchmark.__init__(self)

    def load(self):
        from imgutils.detect.nudenet import _open_nudenet_yolo, _open_nudenet_nms
        _ = _open_nudenet_yolo()
        _ = _open_nudenet_nms()

    def unload(self):
        from imgutils.detect.nudenet import _open_nudenet_yolo, _open_nudenet_nms
        _open_nudenet_yolo.cache_clear()
        _open_nudenet_nms.cache_clear()

    def run(self):
        image_file = random.choice(self.all_images)
        _ = detect_with_nudenet(image_file)


if __name__ == '__main__':
    create_plot_cli(
        [
            ('Nudenet', NudenetDetectBenchmark()),
        ],
        title='Benchmark for Anime NudeNet Detections',
        run_times=10,
        try_times=20,
    )()
+2237 −0

File added.

Preview size limit exceeded, changes collapsed.

+19 −0
Original line number Diff line number Diff line
from imgutils.detect.nudenet import _LABELS, detect_with_nudenet
from imgutils.detect.visual import detection_visualize
from plot import image_plot


def _detect(img, **kwargs):
    return detection_visualize(img, detect_with_nudenet(img, **kwargs), _LABELS)


if __name__ == '__main__':
    image_plot(
        (_detect('censor/nude_girl.png'), 'simple nude'),
        (_detect('censor/simple_sex.jpg'), 'simple sex'),
        (_detect('censor/complex_pose.jpg'), 'complex pose'),
        (_detect('censor/complex_sex.jpg'), 'complex sex'),
        columns=2,
        figsize=(9, 9),
        autocensor=False,
    )
Loading