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.
- 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
- 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:
- Open the Anaconda Prompt (Start Menu → Anaconda Prompt).
- (Optional but recommended) Create/activate your project env (or reuse
yolo_webcam):conda activate yolo_webcam
- Next, run this command:
pip install label-studio
- Finally, activate label-studio by pasting:
label-studio start
- Click “Create Project” → name it (e.g., “Face Recognition”).
- Go to Project → Labeling Interface → choose “Object Detection with Bounding Boxes” or paste a custom template.
- 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, …
- Project → Data Import → upload your raw images (e.g., from data/raw/).
- Label every image:
- Draw bounding boxes around each face.
- Assign the correct class label.
- Aim for variety and balanced classes if using multiple identities.
- Click “Export” → choose “YOLO” with images.
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
Follow the structure of the YAML in Repo
Model training is fairly straightfoward. After creating your dataset, load Model Training.ipynb and replace file path with the YAML from Step F
- Utilize Google CoLab for built in GPU, this is a dependecny of Ultralytics
- Export the file to ONNX for faster end to end inference
You must run testing inside a dedicated Anaconda environment to ensure compatible package versions.
- Open Anaconda Navigator.
- Go to the “Environments” tab → click “Import”.
- Browse to
yolowebcam.yamland select it. - Name the environment (e.g.,
yolo_webcam) and click “Import”. Wait for all packages to resolve and install. - After import:
- In Navigator, select the
yolo_webcamenvironment. - Launch a Terminal (or VS Code/Jupyter) from within this environment
- In Navigator, select the
- Open Model Testing.py inside of this enviroment and put correct file path
See video for example test case