Lanyard Detector - School Safety AI

This model detects whether a person is wearing a lanyard/ID badge around their neck.

🎯 Use Case

Problem: Manual lanyard checking at school entrances is time-consuming.

Solution: Automated computer vision system for real-time lanyard detection.

SDG Impact: SDG 16 (Peace, Justice & Strong Institutions) - School safety

πŸ“Š Model Details

  • Architecture: MobileNetV2 (Transfer Learning)
  • Input: RGB images (224x224)
  • Output: Binary classification
    • Class 0: has_lanyard
    • Class 1: no_lanyard
  • Framework: PyTorch

πŸš€ Quick Start

import torch
from torchvision import transforms, models
from PIL import Image

# Load model
checkpoint = torch.load('pytorch_model.pth', map_location='cpu')
model = models.mobilenet_v2()
model.classifier[1] = torch.nn.Linear(1280, 2)
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()

# Preprocess
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

# Predict
img = Image.open('test.jpg')
img_tensor = transform(img).unsqueeze(0)

with torch.no_grad():
    output = model(img_tensor)
    probs = torch.softmax(output, dim=1)
    pred_class = output.argmax(1).item()
    
classes = ['has_lanyard', 'no_lanyard']
print(f"Prediction: {classes[pred_class]}")
print(f"Confidence: {probs[0][pred_class]*100:.1f}%")

πŸ“ Training Details

  • Custom dataset with data augmentation
  • 70% train / 15% val / 15% test split
  • Adam optimizer (lr=0.001)
  • 15 epochs

⚑ Deployment

Deploy via:

  • Featherless AI (Hugging Face partner)
  • ONNX Runtime
  • TorchScript
  • Edge devices

⚠️ Limitations

  • Best with frontal/slight side angles
  • Requires adequate lighting
  • May struggle with very small/distant lanyards

πŸ“„ License

MIT License


Developed for: Goals in Code Hackathon 2026
SDG: 16 - Peace, Justice & Strong Institutions

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support