Giter Club home page Giter Club logo

face-detection's Introduction

Face Detection Project

Overview

This project implements four different face detection algorithms: OpenCV Haar Cascade, YOLOv8Face, RetinaFace, and MTCNN. It provides a Python module for face detection with visualization options.

Usage

git clone https://github.com/Ali-Fayzi/face-recognition.git
cd face-recognition
pip install -r requirements.txt
import warnings
warnings.filterwarnings("ignore")
import cv2
from time import time 
from matplotlib import pyplot as plt
from face_detection.detections import Face_Detection

if __name__ == "__main__":
    print("Face Detection Model")
    fig = plt.figure(figsize=(20, 10))
    
    # create face detection instance
    face_detection_models = ["opencv", "yolo", "retinaface_v1","retinaface_v2", "mtcnn"]
    
    for idx, face_detector in enumerate(face_detection_models):
        image_path        = r"./test_images/1.png"
        image             = cv2.imread(image_path)
        image             = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        tic = time()
        face_detection    = Face_Detection(model_name=face_detector)
        return_crops      = True
        return_keypoints  = True if face_detector != "opencv" else False
        draw_bbox         = True
        draw_keypoint     = True if face_detector != "opencv" else False 
        main_image, bboxes, keypoints, crops  = face_detection.detect(image=image,
                                                                  return_crops=return_crops,
                                                                  return_keypoints=return_keypoints,
                                                                  draw_bbox=draw_bbox,
                                                                  draw_keypoint=draw_keypoint)
        toc = time()
        plt.subplot(1, len(face_detection_models), idx+1)
        plt.title(f"Detector : {face_detector} , time:{toc-tic:.4} S")
        plt.imshow(main_image, cmap='gray')
    
    plt.show()

Face Detection Result

face-detection's People

Contributors

ali-fayzi avatar

Stargazers

Mohammad Fayzi avatar Amin Tohidi avatar Cioclea Doru Octavian avatar  avatar Sothy Chanty avatar Heydar Mahmoodi avatar

Watchers

 avatar

Forkers

dorucioclea

face-detection's Issues

More fair comparasion

First of all good job, but I think in Retina to compare with other face detection models you have to use different backbone. Because your testing times is slower but more accuracy. I believe that if you test with image which has a lot of faces with different face alignments Retina will get the most accuracy. Becuase in your testing your are using Retina with backbone Resnet50 (96~ MB). I recommend using mobilenet0.25 (1.7~ MB) and then you will get less testing time and it is more fair comparison. Cascade, MTCNN, not accurant in WILD case. Please try with different backbone and also add 'SCRFD' face detection too (one of the latest).

Good luck (:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.