Spaces:
Running on T4
Download docs/TRACKING_VALIDATION.md from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 6.05 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/docs/TRACKING_VALIDATION.md
- Command line
-
hf download hf://spaces/modventures/baseball-engine/docs/TRACKING_VALIDATION.md
-
curl -L -o TRACKING_VALIDATION.md https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/docs/TRACKING_VALIDATION.md
Bat/ball timing verification — 13 October 2026
The implementation is present and tested; its real-video measurement accuracy is not established. The public models are candidates, not proven winners for our capture conditions.
Models and reproducibility
tools/setup_tracking_models.py downloads two pinned public BaseballCV checkpoints and verifies SHA-256 before loading/exporting. Model identities come from the actual checkpoint heads, not the registry's brief description:
| Branch | Checkpoint | Actual output |
|---|---|---|
| Bat | bat_tracking_v2.pt |
YOLO11x pose, bat/hitter classes, four shaft landmarks. The outer observed pair estimates bat ends; independent hand proximity can establish knob/barrel identity without replacing either endpoint. |
| Ball | ball_tracking_v4-YOLOv11.pt |
YOLO11x detection, glove/homeplate/baseball/rubber. Only the baseball class is used. |
Registry snapshot: BaseballCV commit c3c26c979766b28e0c78c3fee2edc2aa3dad571e. Source URLs, checkpoint hashes, actual classes, input size and exported ONNX hash are saved with each model. Export uses Ultralytics 8.4.175, static 640×640 float32, opset 17, raw output without built-in NMS. Runtime validates the ONNX hash and actual CUDA operator execution. No tracking weights are downloaded during an upload.
The adapter converts BGR to RGB, reverses letterbox/crop transforms, filters actual target classes, suppresses duplicate boxes and rejects missing/non-collinear shaft landmarks. Ball searches include the full image and overlapping crops near the athlete/bat. Tracking concentrates on the detected swing and adjacent endpoint context, preserving empty observations outside those windows.
Verified behavior
Automated checks cover preprocessing/class selection, shaft validity, observation windows, no gap filling, visual incoming/outgoing contact evidence, stationary tee departure, projected overlap rejection, unknown capture time and insufficient cadence. Constructed camera paths test triangulation, miss closest approach, both correction signs, disconnected solutions, position-error instability, search boundaries and unsupported coverage.
The worker-to-HTTP checks use actual video decoding and persistence with constructed model observations. They exercise a hit duration and a two-view miss with all four non-null calculations. Authentication, missing-settings rejection, second-view pairing, terminal upload deletion, checksums, old 3.0/2.0 compatibility and opt-in 3.1 are tested. These tests establish calculation and API behavior, not neural-network accuracy on real players.
Real recording check
The exported ONNX models were run on selected frames from the supplied tee-_walk_through (1080p).mp4 on CPU. The bat is detected before the forward swing, but crop/full-image endpoint predictions can disagree. Around frames 75/80, the strongly blurred bat is not detected. The visible ball on the tee at frame 60 was missed in full-image and targeted crop checks; a separate background baseball candidate was detected instead.
This recording cannot support a trusted automatic contact duration with these observations. Its old arm-extension endpoint does not supply the missing ball contact. No threshold was lowered, missing endpoint invented, or per-video coordinate fix added to force a result. The local evaluation images and raw observations are in ignored artifacts/load-timing-validation/; the recordings and artifacts are not committed.
Only selected frames were checked. This is a demonstrated failure case, not a dataset-wide detection-rate estimate. Local CPU timings are not GPU performance measurements. The Linux Docker image and CUDA worker need deployment verification: the local Docker daemon was unavailable and this machine has no NVIDIA GPU.
What still needs evidence
The public checkpoints need evaluation and likely fine-tuning for the intended phone footage, especially blurred bats, balls on tees, nets, backgrounds, small incoming balls and object identity near contact. A temporal baseball model can be evaluated as another candidate; a tennis/shuttlecock checkpoint is not treated as validated baseball tracking.
Reliable early/late measurements additionally need synchronized calibrated views, defensible spatial/interpolation error bounds, and complete physical trajectories. More decimal places or a SAM body mesh do not supply those observations. Forward hand-onset accuracy also remains unvalidated. Keep all confidences as estimates and retain nulls/reasons until independent checks establish reliable measurement errors.
The same ONNX adapter was also checked on frames 169, 185 and 200 of IMG_1610.mp4, using athlete boxes from its archived pose result after verifying the original video's SHA-256. No bat was detected in those samples; one ball candidate was present at frame 200. This is another limited sample check, not validation of that candidate or a full-video accuracy score.
Exporting a replacement detector
The inference adapter is separate from contact/geometry calculations. An improved trusted YOLO checkpoint can be exported with --bat-checkpoint or --ball-checkpoint without changing measurement logic. The bat checkpoint must predict at least two visible landmarks representing its shaft ends; a box-only model is rejected. The ball checkpoint must have one unambiguous baseball or ball class. The local source checkpoint and exported ONNX hashes are recorded. This interface does not train or validate the replacement model.
In an export environment with CPU PyTorch/Torchvision and requirements-tracking-export.txt installed, run:
python -m tools.setup_tracking_models --output downloads --bat-checkpoint /path/to/trusted-bat.pt --ball-checkpoint /path/to/trusted-ball.pt
Install the resulting tracking_bat and tracking_ball directories in the server's model root and restart for CUDA preflight. Keep the required person/body models in that root. The default Docker build uses the pinned public candidates.