notAI-tech / NudeNet

Lightweight nudity detection
https://nudenet.notai.tech/
GNU Affero General Public License v3.0
1.76k stars 342 forks source link

Handle multiple input formats #82

Closed padmalcom closed 3 years ago

padmalcom commented 3 years ago

This pull requests allows to handle multiple inputs for the classifier:

bedapudi6788 commented 3 years ago

@padmalcom if I understand this correctly, you added support for passing opencv image to .classify directly, right?

padmalcom commented 3 years ago

Exactly, detect() allows passing opencv frames, but classify() didn't, so I added a check for the parameter type and did the conversion where required.

bedapudi6788 commented 3 years ago

although undocumented, classify too allows opencv frames, but only when passed as a batch.

for example, the following works.

import cv2
from nudenet import NudeClassifier
classifier = NudeClassifier()
classifier.classify([cv2.imread('image.jpg')])
padmalcom commented 3 years ago

Okay, I wasn't aware of that option. Feel free to reject or accept the pull request.

bedapudi6788 commented 3 years ago

@padmalcom thanks for the report and suggested fix.

updated this by https://github.com/notAI-tech/NudeNet/blob/6ebf23727bf4f13abc6391410d78d1f3693a54c5/nudenet/classifier.py#L111 .

available from nudenet>=2.0.9