Instructions to use RodrigoQuelhas/hyrox-wallballs-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use RodrigoQuelhas/hyrox-wallballs-detection with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("RodrigoQuelhas/hyrox-wallballs-detection", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
HYROX wall balls detection
Detects the medicine ball and the wall target in footage of HYROX wall balls. Built for Wall Ball Judge, a phone app that judges wall-ball reps. The app source is at RomarQ/wall-ball-judge.
Not affiliated with or endorsed by HYROX.
The model on throws from four of my recordings, at their own speed.
Labels
| id | name | what it is |
|---|---|---|
| 0 | ball |
the medicine ball, in the hands or in the air |
| 1 | target |
the mark or plate on the wall the ball must hit |
Files
The same model at three input sizes, each in ONNX and in LiteRT, and its weights.
| input | files | use |
|---|---|---|
| 320 | detector-320.onnx, detector-320.tflite |
fastest, for a 320-pixel crop of a frame 640 pixels wide, such as a window around the target |
| 416 | detector-416.onnx, detector-416.tflite |
faster, for the whole of every frame of a video |
| 640 | detector-640.onnx, detector-640.tflite |
more detail, for small or distant targets |
| 640 | detector.pt |
the trained weights, to fine-tune or to export at another size with Ultralytics |
Usage
With Ultralytics:
from ultralytics import YOLO
model = YOLO("detector-416.onnx", task="detect")
model.predict("frame.jpg", imgsz=416, conf=0.8, iou=0.1, save=True) # writes runs/detect/predict/frame.jpg
Without it, with numpy, onnxruntime and opencv-python, python detect.py frame.jpg writes boxed.jpg:
import sys
import cv2
import numpy as np
import onnxruntime as ort
SIZE = 416 # 640 for detector-640.onnx
LABELS = ["ball", "target"]
image = cv2.imread(sys.argv[1])
# Shrink a picture wider than 640 pixels to 640 across, the width of the training frames.
if image.shape[1] > 640:
image = cv2.resize(image, (640, round(image.shape[0] * 640 / image.shape[1])))
# Fit the picture into a grey square, without stretching it.
scale = SIZE / max(image.shape[:2])
h, w = round(image.shape[0] * scale), round(image.shape[1] * scale)
dx, dy = (SIZE - w) // 2, (SIZE - h) // 2
square = np.full((SIZE, SIZE, 3), 114, np.uint8)
square[dy : dy + h, dx : dx + w] = cv2.resize(image, (w, h))
pixels = square[:, :, ::-1].transpose(2, 0, 1)[None].astype(np.float32) / 255
# Each column is a candidate: centre x, centre y, width, height, then a score per label.
out = ort.InferenceSession(f"detector-{SIZE}.onnx").run(None, {"images": pixels})[0][0]
label, score = out[4:].argmax(0), out[4:].max(0)
boxes = np.stack([out[0] - out[2] / 2 - dx, out[1] - out[3] / 2 - dy, out[2], out[3]], 1) / scale
# Keep the candidates scoring 0.8 or more, and the best of those covering one object.
for i in cv2.dnn.NMSBoxesBatched(boxes, score, label, 0.8, 0.1):
x, y, bw, bh = map(int, boxes[i].round())
cv2.rectangle(image, (x, y), (x + bw, y + bh), (0, 200, 255), 2)
cv2.putText(image, f"{LABELS[label[i]]} {score[i]:.2f}", (x, max(y - 5, 15)), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 200, 255), 2)
cv2.imwrite("boxed.jpg", image)
The .tflite files take the same input and give the same columns, with LiteRT in place of onnxruntime. Their box values are fractions of the input, so multiply them by SIZE first.
Training
Fine-tuned from Ultralytics' YOLO26n, which Ultralytics trained on Objects365 and then COCO.
Licence
AGPL-3.0, inherited from the Ultralytics YOLO26 weights.
- Downloads last month
- 240
Model tree for RodrigoQuelhas/hyrox-wallballs-detection
Base model
Ultralytics/YOLO26