Giter VIP home page Giter VIP logo

yolov9-face-detection's Introduction

YOLOv9 for Face Detection

The face detection task identifies and pinpoints human faces in images or videos. This repo demonstrates how to train a YOLOv9 model for highly accurate face detection on the WIDER Face dataset.

⚙️ Installation

Clone this repo and install requirements.txt for YOLOv9:

git clone https://github.com/spacewalk01/yolov9-face-detection
cd yolov9-face-detection/yolov9
pip install -r requirements.txt

🤖 Pretrained Model

Download the pretrained yolov9-c.pt model from google drive. Note that this model was trained on the WIDER dataset for 240 epochs.

📚 Data Preparation

The WIDER dataset comprises of more than 30k images with more than 390k faces, each with bouding box and other various label formats.

Dataset structure

${ROOT}
└── yolov9
└── datasets/    
    └── widerface/
        └── train/
        └── val/
    └── original-widerface/
        └── train/
            └── images/
            └── label.txt
        └── val/
            └── images/
            └── label.txt
└── train2yolo.py
└── val2yolo.py
└── widerface.yaml

To prepare the data:

  1. Download the WIDER-FACE datasets.
  2. Download the annotation files from google drive.

Run the following commands:

python train2yolo.py datasets/original-widerface/train datasets/widerface/train
python val2yolo.py datasets/original-widerface datasets/widerface/val

These scripts will convert your annotation files to YOLO format, creating one .txt file per image. Each row in the file will represent a single object in the format: class x_center y_center width height.

🏋️ Training

To train the model, use the following command:

cd yolov9
python train_dual.py --workers 4 --device 0 --batch 4 --data ../widerface.yaml --img 640 --cfg models/detect/yolov9-c.yaml --weights '' --name yolov9-c --hyp hyp.scratch-high.yaml --min-items 0 --epochs 500 --close-mosaic 15

🌱 Inference

For inference, run the following command:

python detect.py --weights runs/train/yolov9-c5/weights/best.pt --source assets/worlds-largest-selfie.jpg

Or if you want to use the trained model, download it from the above link and run the following command:

python detect.py --weights best.pt --source assets/worlds-largest-selfie.jpg

🔗 Reference

  • YOLOv9 - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
  • WIDER FACE - WIDER FACE: A Face Detection Benchmark
  • YOLO5Face - YOLO5Face: Why Reinventing a Face Detector

yolov9-face-detection's People

Contributors

spacewalk01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yolov9-face-detection's Issues

Running in Windows 10

Thx for your trained model weights.
And if anyone wants to implement this project with the Windows 10 OS. U need to change the code:
python train2yolo.py [datasets/original-widerface/train] [datasets/widerface/train]
python val2yolo.py [datasets/original-widerface] [datasets/widerface/val]
to
python train2yolo.py datasets/original-widerface/train datasets/widerface/train
python val2yolo.py datasets/original-widerface datasets/widerface/val
at Data Preparation Stage

Have you encountered the following problem?

File "/alg_vepfs/private/xxxxx/yolov9/utils/general.py", line 905, in non_max_suppression
device = prediction.device
AttributeError: 'list' object has no attribute 'device'

detecting heads.

Can these weights be used to detecting heads, as well as faces?

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.