Skip to content

fix(yolo-skill): don't require ultralytics on mps when framework_ok is False (backport to master) - #211

Closed
solderzzc wants to merge 1 commit into
masterfrom
fix/yolo-mps-ultralytics-fallback-master
Closed

solderzzc wants to merge 1 commit into
masterfrom
fix/yolo-mps-ultralytics-fallback-master

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Summary

Backport of #210 (already merged to develop) to master.

master is the branch the Aegis-AI app's skill installer actually clones from at install/reinstall time (skill-registry-service.cjs fetches skills.json off master and git sparse-checkouts the skill from there) — develop isn't in that path at all, so #210 alone doesn't reach any installed skill. This PR ports the identical fix to master so a skill reinstall actually picks it up.

  • 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.
  • 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

  • skills/lib/test_env_config_mps_fallback.py (3 tests) re-verified against current master — passes.
  • Ran full skills/lib/test_env_config_*.py suite on master — 4 pre-existing failures in test_env_config_ane.py reproduce identically on master without this change (unrelated to this fix, not introduced by it; verified by temporarily reverting just the two env_config.py files back to master's version and re-running).
  • Not yet verified against Brian's actual machine — this PR unblocks him reinstalling the yolo-detection-2026 skill from the Aegis-AI Skills sidebar to pick it up.

🤖 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

Copy link
Copy Markdown
Member Author

Closing — this repo's branch strategy only allows develop→master PRs (per CI's check-target job). Reopening the same fix as a develop→master PR instead.

@solderzzc solderzzc closed this Sep 17, 2026
@solderzzc
solderzzc deleted the fix/yolo-mps-ultralytics-fallback-master branch September 17, 2026 00:41
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