A real-time, two-stage computer vision system that checks for school uniform compliance and ID card presence using a live webcam feed.
UNIPECT uses two independently trained image classification models to enforce uniform compliance at entry points — no human checker required.
Stage 1 — Uniform check: The system captures 5 frames from the webcam and runs each through a MobileNet-based model trained on Teachable Machine. It averages the confidence scores across frames to reduce false positives from motion blur or lighting variation.
Stage 2 — ID card check: If the uniform check passes, a second model activates to verify whether the person is wearing a visible ID card. The final result is one of three states: fully compliant (green), uniform only — missing ID (red), or not in uniform (red).
Both checks run in a background thread so the GUI stays responsive throughout.
| State | Result |
|---|---|
| Uniform + ID card | Green screen — "You are in uniform" + "You are wearing an ID card" |
| Uniform, no ID | Red screen — "But you aren't wearing an ID card!" |
| No uniform | Red screen — "You are not in uniform!" |
| Tool | Purpose |
|---|---|
| Python 3.x | Core language |
| TensorFlow / Keras | Model loading and inference |
| Teachable Machine | Model training (transfer learning on MobileNet) |
| OpenCV | Webcam capture and frame preprocessing |
| Tkinter + PIL | Desktop GUI and live video display |
| Threading | Non-blocking inference during UI updates |
UNIPECT/
├── models/
│ ├── main/
│ │ ├── keras_model.h5 # Uniform detection model
│ │ └── labels.txt # Class labels for uniform model
│ └── id/
│ ├── keras_model.h5 # ID card detection model
│ └── labels.txt # Class labels for ID model
├── mods/
│ └── ID.py # ID card check module
├── test/ # Test images / scripts
├── root.py # Main GUI application (run this)
├── main.py # Headless CLI version
├── requirements.txt
└── .gitignore
Webcam
│
▼
Capture 5 frames
│
▼
Resize to 224×224 → Normalize to [-1, 1]
│
▼
Stage 1: Uniform model inference (avg. confidence across 5 frames)
│
├── mean < 50% → NOT IN UNIFORM → Red UI
│
└── mean ≥ 50% → IN UNIFORM
│
▼
Stage 2: ID card model inference (5 frames)
│
├── mean < 50% → MISSING ID → Red UI
│
└── mean ≥ 50% → FULLY COMPLIANT → Green UI
The CustomDepthwiseConv2D wrapper silently drops the groups argument that Teachable Machine exports into the model config but that Keras does not support — allowing clean model loading without modifying the .h5 file.
Prerequisites: Python 3.9–3.11, a working webcam, pip.
# 1. Clone the repo
git clone https://github.com/Sangeeth-Roshan/UNIPECT.git
cd UNIPECT
# 2. Create and activate a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txtWindows note: If
opencv-pythonfails to open the webcam, try installingopencv-python-headlessinstead.
macOS note: Tkinter may require a separate install:
brew install python-tk.
python root.pyClick Start Inspection to begin. The system will run Stage 1, then Stage 2 automatically. Use Check Again to reset for the next person.
python main.pyRuns the same two-stage check without a GUI. Outputs class names and confidence scores to the terminal.
UNIPECT uses models trained with Google Teachable Machine.
- Go to Teachable Machine → Image Project → Standard image model.
- Create two classes (e.g.
uniform/no_uniform). - Train and export as Keras → download the
.h5model andlabels.txt. - Place under
models/main/(uniform model) ormodels/id/(ID card model).
The models are not included in this repo due to file size. You will need to train your own on your institution's uniform.
Sangeeth Roshan github.com/Sangeeth-Roshan linkedin.com/in/rsangeethroshan