How to use the nudenet.detector.Detector.detection_model.predict_on_batch function in nudenet

To help you get started, we’ve selected a few nudenet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bedapudi6788 / NudeNet / nudenet / detector.py View on Github external
def detect(self, img_path, min_prob=0.6):
        image = read_image_bgr(img_path)
        image = preprocess_image(image)
        image, scale = resize_image(image)
        boxes, scores, labels = Detector.detection_model.predict_on_batch(np.expand_dims(image, axis=0))
        boxes /= scale
        processed_boxes = []
        for box, score, label in zip(boxes[0], scores[0], labels[0]):
            if score < min_prob:
                continue
            box = box.astype(int).tolist()
            label = Detector.classes[label]
            processed_boxes.append({'box': box, 'score': score, 'label': label})
            
        return processed_boxes