import os import cv2 from nudenet import NudeClassifier, NudeDetector video_path = 'p**n.mp4' classifier = NudeClassifier() dic = classifier.classify_video(video_path, batch_size=4) # dic = classifier.classify('example.jpg') # detector = NudeDetector() # dic = detector.detect('example.jpg') print(dic) video = cv2.VideoCapture(video_path) print(video.isOpened()) fps = video.get(cv2.CAP_PROP_FPS) length = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) print("fps:", fps, "length", length) # print(os.getcwd())
classifier = NudeClassifier() # Classify single image # dic = classifier.classify('test.jpg') # print(dic) # Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}} # Classify multiple images (batch prediction) # batch_size is optional; defaults to 4 # classifier.classify(['path_to_image_1', 'path_to_image_2'], batch_size=BATCH_SIZE) # # Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}, # # 'path_to_image_2': {'safe': PROBABILITY, 'unsafe': PROBABILITY}} # # Classify video # # batch_size is optional; defaults to 4 dic = classifier.classify_video('p**n.mp4') # print("\n\n\n") # for key, value in dic['preds'].items(): # print('프레임 {}의 결과 값은 {} 입니다'.format(key, value)) count = 0 num_frames = 0 for key, value in dic['preds'].items(): if float(value['unsafe']) > 0.6: count += 1 num_frames += 1 # print("count:{} num_frames:{}".format(count, num_frames)) prop = count / num_frames