Skip to content

joebowen/KOTK-Facial-Recognition

Repository files navigation

Face Recognition System - YOLOv12

📋 Overview

Custom facial recognition system built using Ultralytics YOLOv12, trained on a personal dataset of friends' photographs, Model training perfomed in Google Colab and tested locally in VS Code.

Tech Stack

  • Model: YOLOv12 (Ultralytics)
  • Computer Vision Tools: Label-Studio
  • Language: Python 3.8+
  • Training: Google Colab GPU
  • Key Libraries: ultralytics, opencv-python, numpy, torch (CPU build), onnxruntime

Steps to perform facial recognition:

1. Annotating Images with Label Studio

  • The first step in this process is to actually curate a dataset to train a model on. The more images the better. to do so:

A. Install and Launch Label Studio from Anaconda Prompt (Windows)

  1. Open the Anaconda Prompt (Start Menu → Anaconda Prompt).
  2. (Optional but recommended) Create/activate your project env (or reuse yolo_webcam):
    conda activate yolo_webcam
  3. Next, run this command:
    pip install label-studio
  4. Finally, activate label-studio by pasting:
     label-studio start
    

B. Create a New Object Detection Project and Define Classes

  1. Click “Create Project” → name it (e.g., “Face Recognition”).
  2. Go to Project → Labeling Interface → choose “Object Detection with Bounding Boxes” or paste a custom template.
  3. Add classes exactly as you will use them in training (names list in the dataset YAML):
    • Single-class detector: face
    • Multi-class identities: person_a, person_b, person_c, …

C. Import Images and Label All Images, export when complete

  1. Project → Data Import → upload your raw images (e.g., from data/raw/).
  2. Label every image:
    • Draw bounding boxes around each face.
    • Assign the correct class label.
  3. Aim for variety and balanced classes if using multiple identities.
  4. Click “Export” → choose “YOLO” with images.

D. Create/Arrange to the Project Structure

Organize the exported files into the YOLO layout and split into train/val/test (e.g., 70/20/10):

facial-recognition/
├── dataset/
│   ├── images/
│   │   ├── train/      # your training images
│   │   ├── val/        # your validation images
│   │   └── test/       # your test images
│   └── labels/
│       ├── train/      # matching .txt labels for train images
│       ├── val/        # matching .txt labels for val images
│       └── test/       # matching .txt labels for test images

F. Create the Dataset YAML

Follow the structure of the YAML in Repo

2. Model Training

Model training is fairly straightfoward. After creating your dataset, load Model Training.ipynb and replace file path with the YAML from Step F

Key Notes

  1. Utilize Google CoLab for built in GPU, this is a dependecny of Ultralytics
  2. Export the file to ONNX for faster end to end inference

3. Model Testing

You must run testing inside a dedicated Anaconda environment to ensure compatible package versions.

Steps to setup Anaconda Navigator

  1. Open Anaconda Navigator.
  2. Go to the “Environments” tab → click “Import”.
  3. Browse to yolowebcam.yaml and select it.
  4. Name the environment (e.g., yolo_webcam) and click “Import”. Wait for all packages to resolve and install.
  5. After import:
    • In Navigator, select the yolo_webcam environment.
    • Launch a Terminal (or VS Code/Jupyter) from within this environment
  6. Open Model Testing.py inside of this enviroment and put correct file path

Test Case

See video for example test case

About

Utilizing Ultralytics framework for facial recognition of me and my friends

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors