| |
|
| | from tqdm.auto import tqdm
|
| |
|
| | from nudenet import NudeDetector
|
| |
|
| |
|
| | NUDE_KEYS = [
|
| | "FEMALE_BREAST_EXPOSED",
|
| | "FEMALE_GENITALIA_EXPOSED",
|
| | "MALE_BREAST_EXPOSED",
|
| | "MALE_GENITALIA_EXPOSED",
|
| | "BUTTOCKS_EXPOSED",
|
| | "ANUS_EXPOSED",
|
| |
|
| |
|
| |
|
| | ]
|
| |
|
| | def if_nude(res, threshold=0.2):
|
| |
|
| | return any([ (key in res.keys()) and (res[key] > threshold) for key in NUDE_KEYS ])
|
| |
|
| | def detectNudeClasses(img_paths, threshold=0.2):
|
| |
|
| | print(threshold, "here")
|
| |
|
| | detector = NudeDetector('Eval/320n.onnx')
|
| | results = []
|
| | for img in tqdm(img_paths):
|
| | detected = detector.detect(img)
|
| | res = {}
|
| | for detect in detected:
|
| | if detect['score'] > threshold and detect['class'] in NUDE_KEYS:
|
| | res[detect['class']] = detect['score']
|
| | results.append(res)
|
| | return results
|
| |
|