<jupyter_start><jupyter_text>IMAGENS: NORMAIS<jupyter_code>path = '/mnt/c/Users/guilo/mba-tcc/data/training/safe/*'
files = glob.glob(path)
len(files)
path = '/mnt/c/Users/guilo/mba-tcc/data/testing/safe/*'
files = glob.glob(path)
len(files)
path = '/mnt/c/Users/guilo/mba-tcc/data/training/nude/*'
files = glob.glob(path)
len(files)
path = '/mnt/c/Users/guilo/mba-tcc/data/testing/nude/*'
files = glob.glob(path)
len(files)
path = '/mnt/c/Users/guilo/mba-tcc/data/training/sexy/*'
files = glob.glob(path)
len(files)
path = '/mnt/c/Users/guilo/mba-tcc/data/testing/sexy/*'
files = glob.glob(path)
len(files)

path = r'C:\Users\guilo\mba-tcc\data\test\safest\*.jpg'
files = glob.glob(path)
imagem = np.random.choice(files)
# arquivo = imagem.replace('/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/safe/', '').replace('.jpg', '')
imagem


original_image = cv2.cvtColor(cv2.imread(imagem),cv2.COLOR_BGR2RGB)

figure_size = 10
plt.figure(figsize=(figure_size,figure_size))
plt.imshow(original_image)
# plt.title('Imagem Original')
plt.xticks([]), plt.yticks([])
plt.show()
cv2.imread(imagem).shape
def predict_single_image(image_path):
    
    image_data = image.load_img(image_path, target_size=(height, width))
    image_array = image.img_to_array(image_data)
    image_array /= 255

    plt.imshow(image_array);
    plt.axis('off');

    x_train = []
    x_train.append(image_array)
    x_test = np.array(x_train)

    predictions = model.predict(x_test)
    print(f'Not Safe: {round(predictions[0][0]*100, 2)}%')
    print(f'Safe: {round(predictions[0][1]*100, 2)}%')
predict_single_image(r'C:\\Users\\guilo\\mba-tcc\\data\\test\\safest\\safest_3426.jpg')
    image_data = image.load_img(imagem, target_size=(299, 299))

    # Convert the loaded image file to a numpy array
    image_array = image.img_to_array(image_data)
    image_array /= 255
model.predict(np.array(image_array))
safe = predict.classify(model, imagem)
results[arquivo] = safe[imagem]
safe<jupyter_output><empty_output><jupyter_text>IMAGENS: SEXY<jupyter_code>path = '/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/sexy/*.jpg'
files = glob.glob(path)
imagem = np.random.choice(files)
arquivo = imagem.replace('/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/sexy/', '').replace('.jpg', '')
imagem
# original_image = cv2.cvtColor(cv2.imread(imagem),cv2.COLOR_BGR2RGB)

# figure_size = 10
# plt.figure(figsize=(figure_size,figure_size))
# plt.imshow(original_image)
# plt.title('Imagem Original')
# plt.xticks([]), plt.yticks([])
# plt.show()
sexy = predict.classify(model, imagem)
results[arquivo] = sexy[imagem]
sexy<jupyter_output>/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/sexy/BC546DD0-82EB-4C98-8AD4-C186A660FBD0.jpg size: (224, 224)<jupyter_text>IMAGENS: NUDE<jupyter_code>path = '/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/nude/*.jpg'
files = glob.glob(path)
imagem = np.random.choice(files)
arquivo = imagem.replace('/mnt/d/NUDENET/NudeNet_classifier_dataset_v1/nude_sexy_safe_v1_x320/testing/nude/', '').replace('.jpg', '')
imagem
# original_image = cv2.cvtColor(cv2.imread(imagem),cv2.COLOR_BGR2RGB)

# figure_size = 10
# plt.figure(figsize=(figure_size,figure_size))
# plt.imshow(original_image)
# plt.title('Imagem Original')
# plt.xticks([]), plt.yticks([])
# plt.show()
nude = predict.classify(model, imagem)
results[arquivo] = nude[imagem]
nude
results
for k, v in results.items():
    if (results[k]['porn'] > 0.2) | (results[k]['sexy'] > 0.2) | (results[k]['hentai'] > 0.5):
        print(f'{k}: NUDEZ ENCONTRADA')
    else:
        print(f'{k}: IMAGEM LIVRE')<jupyter_output>335474F7-4F47-457B-B11F-814A59794686: IMAGEM LIVRE
BC546DD0-82EB-4C98-8AD4-C186A660FBD0: NUDEZ ENCONTRADA
BF1FB549-FC45-41D0-A805-F72C1735125E: NUDEZ ENCONTRADA
{'fraction_non_alphanumeric': 0.17006451612903226, 'fraction_numerical': 0.04438709677419355, 'mean_word_length': 5.648370497427101, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '621194', 'license': 'MIT', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1676, 'n_words': 188, 'path': 'NSFW_DETECTOR.ipynb', 'repo_name': 'guilourenzo/nsfw_model', 'size': '3875'}