This project uses YOLOv8 to detect hands with and without gloves in images. It can process a directory of images and will output annotated images as well as JSON files with detection details.
| Input Image | Detected Output |
|---|---|
![]() |
![]() |
This project uses uv for package management.
- Install
uv:pip install uv
To run glove detection on a folder of images, use the main.py script.
uv run main.py <path_to_your_image_folder>For example, to process the sample images provided:
uv run main.py sample_imagesThe annotated images will be saved in the output/ directory, and the detection logs in JSON format will be saved in the logs/ directory.
The dataset used for this project is a custom dataset focused on glove detection, originally sourced from Roboflow: Hang and Glove Detect. It contains images of hands, which will be categorized into 'gloved_hand' and 'bare_hand' after cleaning the dataset.
The primary model used for detection is YOLOv8s (YOLOv8 small), chosen for its balance of performance and efficiency. This model was fine-tuned from a pretrained yolov8s.pt checkpoint.
The training process involved several steps:
- Data Cleaning: Initial data cleaning was performed using
clean_dataset.pyto remove duplicates or corrupted entries and to rename the classes. - Data Splitting: The dataset originally had train set and test set. Validation set was created from 20% of the train set.
- Training: The YOLOv8s model was trained for 75 epochs using the
train.pyscript. Key hyperparameters were configured as follows (fromruns/detect/train3/args.yaml):epochs: 75batch: 16imgsz: 640model: yolov8scos_lr: True (cosine learning rate scheduler)mixup: 0.1flipud: 0.5 (vertical flip augmentation)fliplr: 0.5 (horizontal flip augmentation)
- YOLOv8s Performance: The YOLOv8s model demonstrated strong performance, achieving high Mean Average Precision (mAP) scores on the validation set.
- Hyperparameter Tuning: Extensive hyperparameter tuning was conducted across different training runs (
train,train2,train3,train4). - Model Comparison: While YOLOv8m (from
train4) showed marginally highermAP50-95, YOLOv8s (fromtrain3) was selected as the preferred model due to its comparable performance and significantly smaller size, making it more efficient for deployment. - Initial Models: Earlier training runs with YOLOv8n models showed lower performance compared to the 's' and 'm' variants, indicating the benefit of using larger models for this dataset.

