Downloads · 30 days
0
FatimaNoorAI/helmet-detection
helmet-detection is a machine learning model from FatimaNoorAI. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project detects whether riders are wearing helmets using a pre-trained YOLOv8 model. It can process both videos and real-time webcam feeds to identify helmet usage among bikers. The output video is saved with det…
Downloads · 30 days
0
Access
Public
Updated Aug 24, 2026
Repo size
6.2 MB
Likes
1
Public
Click a slice to open those files.
.pt6.2 MB · 98%
From the Hugging Face model README
This project detects whether riders are wearing helmets using a pre-trained YOLOv8 model. It can process both videos and real-time webcam feeds to identify helmet usage among bikers. The output video is saved with detection boxes labeled as "Helmet" or "No Helmet".
Example detection results on bikers --- showing bounding boxes for helmet and no helmet riders. Without Helmet <img width="1251" height="763" alt="image" src="https://github.com/user-attachments/assets/e608c822-a30c-4580-b8fa-637d7bc327ce" />
With Helmet
<img width="1461" height="776" alt="image" src="https://github.com/user-attachments/assets/49c11715-594c-4dc2-946c-b632ae4101bc" />YOLOv8sharathhhhh/safetyHelmet-detection-yolov8Ultralytics YOLOv8.pt (PyTorch weights)!pip install ultralytics
from google.colab import drive
drive.mount('/content/drive')
from ultralytics import YOLO
model = YOLO('/content/drive/MyDrive/safetyHelmet.pt')
results = model.predict(
source='/content/drive/MyDrive/helmet_test.mp4',
conf=0.4,
save=True,
project='/content/drive/MyDrive/',
name='helmet_output'
)
The output video will be saved in
/content/drive/MyDrive/helmet_output/.
from IPython.display import HTML
from base64 import b64encode
mp4 = open('/content/drive/MyDrive/helmet_output/helmet_test.mp4','rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML(f'<video width=700 controls><source src="{data_url}" type="video/mp4"></video>')
To use your webcam in Colab or a local Python script:
import cv2
from ultralytics import YOLO
model = YOLO('/content/drive/MyDrive/safetyHelmet.pt')
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
results = model(frame)
annotated_frame = results[0].plot()
cv2.imshow("Helmet Detection", annotated_frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
📂 Helmet-Detection-YOLOv8
┣ 📜 README.md
┣ 📜 safetyHelmet.pt
┣ 📜 helmet_test.mp4
┣ 📜 detect_helmet.py
┗ 📂 helmet_output/
Fatima Noor
BSCS Graduate | AI/ML Enthusiast | Computer Vision Developer
This project is open-source and available for educational and research purposes.