<jupyter_start><jupyter_text>Playground notebookThis notebook is used for demonstration and testing purposes.<jupyter_code>import os
import numpy as np
import pickle
import matplotlib.pyplot as plt
import cv2
from config import DATA_DIR, FACES_DIR<jupyter_output><empty_output><jupyter_text>Find all images<jupyter_code>import os
image_files = []
for root, dirs, files in os.walk(DATA_DIR):
    for file in files:
        if file.endswith(".jpg"):
             image_files.append(os.path.join(root, file))<jupyter_output><empty_output><jupyter_text>Load faces metadata (locations and dimensions)<jupyter_code>with open(os.path.join(FACES_DIR, 'faces.pickle'), 'rb') as f:
    faces_dict = pickle.load(f)<jupyter_output><empty_output><jupyter_text>Show a random image and the face detection windowThe cell below can be run multiple times with ctrl+enter<jupyter_code>img_path = image_files[np.random.randint(len(image_files))]
img_file = os.path.basename(img_path)
img = cv2.imread(img_path)

print(img_file)
print(faces_dict[img_file])
for x, y, w, h in faces_dict[img_file]:
    img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    roi_gray = gray[y:y+h, x:x+w]
    roi_color = img[y:y+h, x:x+w]

plt.figure()
plt.imshow(img) 
plt.show()<jupyter_output>Mel_Gibson_0001.jpg
[[ 69  69 116 116]]
{'fraction_non_alphanumeric': 0.12407132243684993, 'fraction_numerical': 0.019316493313521546, 'mean_word_length': 6.052356020942408, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '147235', 'license': 'MIT', 'n_tokens_mistral': 539, 'n_tokens_neox': 516, 'n_words': 107, 'path': 'src/Playground.ipynb', 'repo_name': 'TvrtkoSternak/CV-face-de-identification', 'size': '1346'}