Skip to content

fix(yolo-skill): don't require ultralytics on mps when framework_ok is False - #210

Merged
solderzzc merged 1 commit into
developfrom
fix/yolo-mps-ultralytics-fallback
Sep 17, 2026
Merged

solderzzc merged 1 commit into
developfrom
fix/yolo-mps-ultralytics-fallback

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Summary

  • load_optimized()'s final fallback branch (taken when the optimized runtime check fails, framework_ok=False) unconditionally imported ultralytics — but mps installs deliberately never ship torch/ultralytics (requirements_mps.txt only lists onnxruntime).
  • Any mps machine where _check_mps_runtime() fails (CoreML execution provider not found) crashed with No module named 'ultralytics' when loading a YOLO skill, instead of falling back to the pre-built .onnx model via plain CPUExecutionProvider.
  • This is one of the bugs reported in SharpAI/DeepCamera#207 — the reporter's exact traceback (Failed to load model: No module named 'ultralytics', backend=mps, framework_ok=False) reproduces this path exactly.

Fix

On the mps backend, that fallback branch now calls _load_onnx_coreml() (already used elsewhere in the same function for the mps happy path) against the pre-built .onnx, instead of assuming ultralytics is importable. If no pre-built .onnx exists either, it raises a clear RuntimeError instead of a confusing ModuleNotFoundError.

Applied identically to both copies of env_config.py (skills/detection/yolo-detection-2026/scripts/ and skills/lib/), matching how #194 touched both.

Test plan

  • New regression test skills/lib/test_env_config_mps_fallback.py (3 tests) — reproduces the exact reported log conditions (backend=mps, framework_ok=False), asserts the ONNX CoreML path is used instead of importing ultralytics, and asserts a clear error when no pre-built model exists.
  • Ran full skills/lib/test_env_config_*.py suite — 4 pre-existing failures in test_env_config_ane.py reproduce identically on develop without this change (unrelated to this fix, not introduced by it).
  • Not yet verified against Brian's actual machine/log — worth confirming with a targeted build the way Says SwiftLM Not Installed #207's other fixes were (0.2.10–0.2.14).

🤖 Generated with Claude Code

…s False

load_optimized()'s final fallback branch (taken when the optimized
runtime check fails) unconditionally imported ultralytics. mps installs
deliberately ship without torch/ultralytics (requirements_mps.txt: only
onnxruntime is needed), so any mps machine where the CoreML EP check
fails crashed with "No module named 'ultralytics'" instead of falling
back to the pre-built ONNX model via plain CPUExecutionProvider.

Now mps uses _load_onnx_coreml() (already used elsewhere in this same
function) in that branch instead, matching the file's own stated intent.

Addresses one of the symptoms in #207.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@solderzzc
solderzzc merged commit ed07d68 into develop Sep 17, 2026
1 check passed
@solderzzc
solderzzc deleted the fix/yolo-mps-ultralytics-fallback branch September 17, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant