diff options
| author | gdamms <damguillotin@gmail.com> | 2024-06-25 10:44:42 +0200 |
|---|---|---|
| committer | gdamms <damguillotin@gmail.com> | 2024-06-25 10:44:42 +0200 |
| commit | 7c672b2aa95a5ecf493e699bd0f88a90dc619a4f (patch) | |
| tree | c00b0bce6c8558d80db75db11c211d78471c3460 /utils.py | |
| parent | 1011f68c3eafb8b468cf1df23117b98c7c7b55ed (diff) | |
| download | diffusion-mnist-7c672b2aa95a5ecf493e699bd0f88a90dc619a4f.tar.gz diffusion-mnist-7c672b2aa95a5ecf493e699bd0f88a90dc619a4f.zip | |
haar cascade
Diffstat (limited to 'utils.py')
| -rw-r--r-- | utils.py | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -1,6 +1,6 @@ import numpy as np import scipy.linalg -import matplotlib.pyplot as plt +import cv2 def fid(reals, fakes): @@ -77,4 +77,32 @@ def jsd(reals, fakes): hist_avg = (hist_real + hist_fake) / 2 - return 0.5 * (np.mean(np.log(hist_real / hist_avg)) + np.mean(np.log(hist_fake / hist_avg)))
\ No newline at end of file + return 0.5 * (np.mean(np.log(hist_real / hist_avg)) + np.mean(np.log(hist_fake / hist_avg))) + + +def haar(image): + # Load the Haar cascade for face detection + face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') + + # Convert the image to grayscale + gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) + + # Perform face detection + faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=4) + + # Draw rectangles around the detected faces + for (x, y, w, h) in faces: + cv2.rectangle(image, (x, y), (x+w, y+h), (255, 0, 0), 2) + + # Display the result + cv2.imshow('Face Detection', image) + cv2.waitKey(0) + cv2.destroyAllWindows() + + +if __name__ == '__main__': + # Load the image + image = cv2.imread('data/edface/500/03120500_000.png') + + # Perform face detection + haar(image)
\ No newline at end of file |
