Instructions to use dxvyaaa/yolo_helmet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use dxvyaaa/yolo_helmet with ultralytics:
from ultralytics import YOLOvv8 model = YOLOvv8.from_pretrained("dxvyaaa/yolo_helmet") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - YOLOv10
How to use dxvyaaa/yolo_helmet with YOLOv10:
from ultralytics import YOLOvv8 model = YOLOvv8.from_pretrained("dxvyaaa/yolo_helmet") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
| import gradio as gr | |
| from ultralytics import YOLO | |
| import numpy as np | |
| # Load YOLOv8 model | |
| model = YOLO("best.pt") # Make sure best.pt is in the repo root | |
| def predict(image): | |
| # image is numpy array from Gradio | |
| results = model(image)[0] # YOLO prediction | |
| annotated_image = results.plot() # returns numpy array | |
| detections = [] | |
| if results.boxes is not None: | |
| for box, cls, conf in zip(results.boxes.xyxy, results.boxes.cls, results.boxes.conf): | |
| detections.append({ | |
| "label": model.names[int(cls)], | |
| "confidence": float(conf), | |
| "box": [float(coord) for coord in box] | |
| }) | |
| return annotated_image, detections | |
| # Gradio interface | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="numpy"), | |
| outputs=[gr.Image(type="numpy"), gr.JSON()], | |
| title="Helmet Detection YOLOv8", | |
| description="Upload an image and detect helmet / head using YOLOv8" | |
| ) | |
| demo.launch() | |