Custom Weights Guide
How to use Ollama vision as an add-on, and how to train or plug in your own detector weights for this project.Short Answer: Can Ollama Vision Models Be Used?
Yes, but as an add-on layer, not as the main detector. This app's video pipeline is built around Ultralytics object detection, which is fast enough to scan full videos frame-by-frame. Ollama vision models are better for reasoning over selected frames or short clips.
Good add-on uses: reviewing candidate events, summarizing a clip, comparing reruns, explaining why a possession was tagged a certain way, or labeling a handful of already-detected moments. Poor fit: scanning an entire game video frame-by-frame as the primary detector.
Recommended Ollama Vision Use Cases
Event verification
Human-readable summaries
Side-by-side rerun comparisons
High-FPS object tracking
Replacing YOLO for bounding boxes
Real-time frame-by-frame inference
Examples of vision-capable Ollama families to evaluate for add-on workflows include models like llava, qwen2.5vl, or minicpm-v when they are available in your Ollama environment. Treat them as reviewers or describers, not as the detector that populates detections.
Important Limitation in the Current App
The current analyzer only persists person and ball detections into the database. If you train a custom model with extra classes like rim, referee, made_shot, or screen, those classes will not automatically show up in the app until the analyzer/event pipeline is expanded to store and use them.
So today, the safest custom-weight strategy is to train a model that is still excellent at person and ball detection in your gym and camera angles. That alone can improve downstream tracking and event heuristics.
How to Create Your Own Custom Weights
- Choose the exact classes you want. For the current app, start with
personandball. Add more classes only if you also plan to expand the code that consumes them. - Collect representative footage. Use clips from your actual gym, scoreboard lighting, camera height, sideline angle, uniforms, and ball color. Variety matters more than total file count.
- Extract frames. Pull frames from games, practices, crowded possessions, fast breaks, rebounds, and bad lighting. Include misses, occlusion, and empty frames so the model learns what not to detect.
- Annotate in YOLO format. Tools like CVAT, Label Studio, or Roboflow can export YOLO detection labels. Keep labeling rules consistent, especially for the ball when it is partially occluded.
- Split the dataset. Create train, validation, and test sets. Keep some games fully out of training so you can tell whether the model generalizes.
- Create a
dataset.yaml. Point it at your train/val folders and define the class names in the exact order used by the labels. - Train from a reasonable base model. Start from a small or medium detector close to your hardware budget, then compare.
- Review the validation output. Look at missed balls, false positives on shoes or logos, and whether player boxes stay stable when defenders overlap.
- Export the best weights. Ultralytics training typically writes a
best.ptfile under the run directory. - Load that weight file into this app. In Settings, choose
Custom Ultralytics weightsand set the custom model field to the local.ptpath or a supported model name. - Rerun AI and compare. Use the compare workflow on the same video to measure whether your custom detector produced better detections or downstream events.
Example Training Command
yolo detect train data=/path/to/dataset.yaml model=yolo11s.pt imgsz=1280 epochs=100 batch=8 device=0 project=training_runs name=liberty-ball-player
If your GPU is small, reduce imgsz or batch size, or start from yolo11n.pt. If you are CPU-only, training will be much slower; consider training elsewhere and copying the resulting best.pt onto this machine.
Suggested Dataset Structure
dataset/
images/train/
images/val/
images/test/
labels/train/
labels/val/
labels/test/
dataset.yaml
Example dataset.yaml
path: /path/to/dataset
train: images/train
val: images/val
test: images/test
names:
0: person
1: ball
What Usually Improves Results the Most
- More examples from your real gym and camera angle
- Cleaner ball labels during occlusion and motion blur
- Frames from difficult possessions, not just easy ones
- Comparing small vs medium models on the same uploaded video
- Using the compare page to test changes one rerun at a time
Practical Workflow for This Project
- Start with
yolo11n.ptoryolo11s.ptin Settings. - If stock weights still miss the ball or merge players too often, train a custom detector focused on your footage.
- Load the resulting
best.ptthrough the custom detector field. - Rerun the same uploaded video and compare counts.
- If you want richer labels later, add Ollama vision as a second-stage reviewer on top of detections rather than replacing the detector.