YOLOv8 Lanyard Detector
A YOLOv8 nano model fine-tuned to detect ID cards/lanyards worn by people. This is Stage 2 of a two-stage detection pipeline for access control and security monitoring.
Model Description
- Model: YOLOv8n (nano) - optimized for speed and efficiency
- Task: Object Detection (Single Class)
- Class:
id_tag(lanyard/ID card detection) - Use Case: Security access control, attendance monitoring, event management
Two-Stage Detection Pipeline
This model is designed to work in a two-stage pipeline:
Stage 1: Person Detection
- Use YOLOv8 COCO pretrained model
- Detects people in the scene
Stage 2: Lanyard Detection (This Model)
- Runs on the full image
- Detects lanyards/ID cards
- Output: Person wearing lanyard β or No lanyard β
Decision Logic
- PASS: Both person AND lanyard detected β Person has valid ID
- FAIL: Person detected but NO lanyard β Access denied
Usage
Install Dependencies
pip install ultralytics opencv-python huggingface_hub
Quick Start
from ultralytics import YOLO
import cv2
# Load model
model = YOLO("harleensachdev/yolo-lanyard-detector")
# Run detection
image = cv2.imread("your_image.jpg")
results = model(image)
# Check if lanyard detected
has_lanyard = len(results[0].boxes) > 0
if has_lanyard:
print("β Lanyard detected - Access granted")
else:
print("β No lanyard - Access denied")
Two-Stage Detector Script
from ultralytics import YOLO
import cv2
# Stage 1: Detect people
person_detector = YOLO("yolov8n.pt") # COCO pretrained
person_results = person_detector(image)
# Check if person detected (class 0 = person in COCO)
has_person = any(int(box.cls[0]) == 0 for box in person_results[0].boxes)
# Stage 2: Detect lanyard
lanyard_detector = YOLO("harleensachdev/yolo-lanyard-detector")
lanyard_results = lanyard_detector(image)
has_lanyard = len(lanyard_results[0].boxes) > 0
# Final decision
if has_person and has_lanyard:
print("β PASS: Person with valid ID")
elif has_person and not has_lanyard:
print("β FAIL: Person without ID")
else:
print("β οΈ No person detected")
Model Performance
- Architecture: YOLOv8n
- Input Size: 640x640
- Parameters: ~3M (lightweight, real-time capable)
- Training Dataset: Custom lanyard detection dataset (908 images)
- Positive examples: 837 images with lanyard annotations
- Negative examples: 71 images without lanyards
- Total annotations: 1,360 bounding boxes
Training Details
- Framework: Ultralytics YOLOv8
- Epochs: 100 (with early stopping)
- Batch Size: 16
- Image Size: 640x640
- Optimizer: Adam
- Data Augmentation:
- Horizontal flip (50%)
- Rotation (Β±10Β°)
- Translation (Β±10%)
- HSV augmentation
- Mosaic augmentation
Intended Use
Primary Applications
- π’ Corporate Access Control: Monitor employee ID badge compliance
- π Educational Institutions: Verify student ID cards
- π₯ Healthcare Facilities: Ensure staff identification
- πͺ Events & Conferences: Attendee credential verification
- π Industrial Sites: Safety and security compliance
Use Cases
- Real-time video surveillance for access control
- Automated attendance systems
- Visitor management
- Security checkpoint automation
- Compliance monitoring
Limitations
- Optimized for frontal/side views of people
- Performance may degrade with:
- Extreme lighting conditions
- Heavy occlusion of lanyard
- Very small or distant subjects
- Non-standard ID badge formats
Ethical Considerations
This model is designed for security and access control purposes within the framework of SDG 16 (Peace, Justice and Strong Institutions). Users should:
- β Ensure compliance with local privacy laws
- β Obtain proper consent when deploying in surveillance systems
- β Use only in authorized security contexts
- β Avoid discriminatory applications
- β Do not use for unauthorized surveillance
Citation
@software{yolov8_lanyard_detector,
author = {Harleen Sachdev},
title = {YOLOv8 Lanyard Detector},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/harleensachdev/yolo-lanyard-object-detector}
}
License
MIT License - See LICENSE file for details
Acknowledgments
- YOLOv8: Ultralytics (https://github.com/ultralytics/ultralytics)
- Goal: SDG 16 - Peace, Justice and Strong Institutions
- Project: Goals in Code Initiative
Contact
For questions or collaboration: [Your contact information]
Last Updated: 2026-02-01