Face-detectionCV is a state-of-the-art computer vision application leveraging RetinaFace, a robust single-stage multi-task deep neural network designed for high-precision human face localization.
Unlike classical Haar cascades or standard HOG detectors, RetinaFace excels at localizing faces of extreme scales (from tiny distant faces to full-frame closeups), severe angles, heavy occlusions (masks, sunglasses, hats), and poor lighting conditions.
- 🏆 State-of-the-Art (SOTA) Accuracy: Employs RetinaFace with a Feature Pyramid Network (FPN) backbone for multi-scale spatial resolution.
- 🔍 Multi-Scale & Small Face Detection: Capable of detecting tiny and distant faces in crowded scenes without degradation in accuracy.
- 📍 Precise Facial Area Localization: Returns exact
[x1, y1, x2, y2]spatial coordinates corresponding tofacial_areabounding boxes. - ⚡ Google Colab Integration: Ready-to-run interactive image upload workflow using
google.colab.filesand rendering withcv2_imshow(). - 🛡️ Occlusion Robust: Maintains detection reliability even when subjects wear masks, glasses, or are turned sideways.
flowchart TD
A["Input Image (Upload via Colab files.upload)"] --> B["Decode with OpenCV cv2.imread()"]
B --> C["RetinaFace.detect_faces(img)"]
subgraph Deep_Learning_Engine["RetinaFace Multi-Task Neural Network"]
C --> D["Feature Pyramid Network (FPN) Feature Extraction"]
D --> E["Multi-Scale Anchor Processing"]
E --> F["Face Bounding Box Regression"]
E --> G["Facial Landmark Localization"]
end
F --> H["Extract Bounding Coordinates: facial_area [x1, y1, x2, y2]"]
H --> I["Iterate Detected Faces in Output Dictionary"]
I --> J["Render Bounding Boxes using cv2.rectangle()"]
J --> K["Display Annotated Image via cv2_imshow()"]
-
Open the Script:
Click the "Open In Colab" badge above or visit Google Colab. -
Run the Code Cell:
Execute the cell to installretina-faceandopencv-python-headless. -
Upload an Image:
When prompted, choose any image from your computer (single person, family photo, or crowded street). -
Instant Detection:
RetinaFace processes the image and outputs the image with precise green bounding boxes highlighting every detected face.
To run the project on your local machine:
-
Clone the repository:
git clone https://github.com/dipzz0/Face-detectionCV.git cd Face-detectionCV -
Install dependencies:
pip install retina-face opencv-python
-
Run the script:
python Face-detection.py
(Note: For local execution, replace
cv2_imshow(img)withcv2.imshow('Faces', img)andcv2.waitKey(0)).
| Technology | Role | Description |
|---|---|---|
| RetinaFace | Face Detector | Deep learning single-stage multi-task face detector |
| OpenCV | Computer Vision | Image reading, array manipulation, and visual bounding box rendering |
| TensorFlow / Keras | Backend | Underpins RetinaFace deep learning inference weights |
| Google Colab | Execution Platform | Zero-config cloud environment |
This project is licensed under the MIT License.
Developed with ❤️ by dipzz0