Skip to content

Commit

Permalink
Create detect_faces.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsimran-Dalal authored Oct 28, 2024
1 parent a713e71 commit 355adf8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions detect_faces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
from PIL import Image

def detect_faces(image_path):
"""Detect faces in the given image path."""
# Validate input
if not os.path.exists(image_path):
raise FileNotFoundError(f"The file {image_path} does not exist.")
if not image_path.lower().endswith(('.png', '.jpg', '.jpeg')):
raise ValueError("Unsupported image format. Please use .png, .jpg, or .jpeg files.")

try:
image = Image.open(image_path)
except IOError:
raise ValueError("The image file is corrupted or cannot be opened.")

# Face detection logic here...
faces = [] # Replace with actual face detection logic
return faces

0 comments on commit 355adf8

Please sign in to comment.