Repository navigation
Add Core ML export support - #172
Merged
Merged
Conversation
aalvsz
force-pushed
the
90-add-coreml-support
branch
from
May 3, 2026 21:06
38ad463 to
582ea36
Compare
Contributor
|
Hi @aalvsz, thanks for the contribution! Before we can review/merge this, could you please clean up the PR by removing any unrelated docs/validation artifacts? Also, could you add a short explanation of how you tested the changes, including the commands or steps we can run locally to verify that everything works? Thanks! |
Contributor
Author
|
Thanks for the review. I’ve now addressed both items. I removed the unrelated/unneeded materials. Committed as: ed94569 Validation run locally:
|
Add CoreML (.mlpackage) as a new export format and a CoreMLBackend that runs the exported model on macOS via coremltools. * Register CoreMLExporter in the BaseExporter registry. * Implement export_coreml() with per-family preprocess wrappers so the traced graph always accepts canonical RGB float in [0, 1]. * Embed Apple's NonMaximumSuppression as a CoreML pipeline when nms=True (raises for RF-DETR; not supported). * Add CoreMLBackend mirroring OnnxBackend; dispatch .mlpackage directories from the LibreYOLO() factory. * Add coremltools optional extra and the 'coreml' pytest marker. * Add unit tests (mock coremltools so they run on Linux) and a macOS-only e2e parity suite. Rebased onto current main, squashing 11 prior commits while preserving the original authorship.
brohoya
force-pushed
the
90-add-coreml-support
branch
from
May 11, 2026 18:51
92fd238 to
150358e
Compare
brohoya
reviewed
May 11, 2026
Comment on lines
+684
to
+689
| class CoreMLExporter(BaseExporter): | ||
| format_name = "coreml" | ||
| suffix = ".mlpackage" | ||
| requires_onnx = False | ||
| supports_int8 = False | ||
| apply_model_half = False # ct.convert handles precision via compute_precision |
Contributor
There was a problem hiding this comment.
Hi @aalvsz, I noticed that CoreMLExporter is missing the supports_fp16 class attribute that every other BaseExporter subclass declares. This makes libreyolo formats crash:
libreyolo formats
╭───────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────╮
│ /home/bix/Documents/libreyolo/libreyolo/cli/commands/special.py:216 in formats_cmd │
│ │
│ 213 │ │ │ "name": name, │
│ 214 │ │ │ "extension": cls.suffix, │
│ 215 │ │ │ "int8": cls.supports_int8, │
│ ❱ 216 │ │ │ "fp16": cls.supports_fp16, │
│ 217 │ │ │ "requires_onnx": cls.requires_onnx, │
│ 218 │ │ } │
│ 219 │ │ if name == "tensorrt": │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: type object 'CoreMLExporter' has no attribute 'supports_fp16'
Fix:
Suggested change
| class CoreMLExporter(BaseExporter): | |
| format_name = "coreml" | |
| suffix = ".mlpackage" | |
| requires_onnx = False | |
| supports_int8 = False | |
| apply_model_half = False # ct.convert handles precision via compute_precision | |
| class CoreMLExporter(BaseExporter): | |
| format_name = "coreml" | |
| suffix = ".mlpackage" | |
| requires_onnx = False | |
| supports_int8 = False | |
| supports_fp16 = True | |
| apply_model_half = False # ct.convert handles precision via compute_precision |
brohoya
force-pushed
the
90-add-coreml-support
branch
from
May 15, 2026 17:07
c0fef03 to
6fc0dad
Compare
Closed
marikazimut
pushed a commit
to marikazimut/libreyolo
that referenced
this pull request
Jun 21, 2026
Add Core ML export support
marikazimut
pushed a commit
to marikazimut/libreyolo
that referenced
this pull request
Jun 21, 2026
Brings to dev: CoreML export+backend (LibreYOLO#172), validation imgsz override honored (LibreYOLO#232), YOLO9 imgsz fix (LibreYOLO#208), 80-class hardcode fix (LibreYOLO#209), README flagship rhetoric (LibreYOLO#233), Chinese README, plus the smaller fixes that landed on main since the last dev sync. Conflict resolution: - pyproject.toml: union extras (keep both `gaze`/`gaze-retinaface` from dev and `coreml` from main); add both `libreyolo[gaze]` and `libreyolo[coreml]` to `all`. Keep dev's `rfdetr = [transformers, scipy]` (native RF-DETR port; do not pull in main's third-party `rfdetr` package). Keep main's tensorrt pin + uv dependency-metadata blocks (auto-merged). Union pytest markers (auto-merged). - validation/detection_validator.py: auto-merged. Main's `_resolve_imgsz` helper and explicit-imgsz fix combine cleanly with dev's TTA additions (`_run_validation_augmented`, `_uses_topk_coco_scoring`, etc.). Main's removal of the `_coco_annotation_file is not None` topk precondition is preserved implicitly via dev's family-only helper. - data/utils.py: auto-merged. PRs LibreYOLO#186/LibreYOLO#192 landed on both sides, so the symlink-resolve and exists-check removals match; dev's Windows-sep handling and multi-split-list support preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.mlpackageoutputsAuthorship
Tests
Related to #90.