Commit ·
83000c1
0
Parent(s):
Duplicate from mlboydaisuke/YOLOX-CoreAI
Browse filesCo-authored-by: Daisuke Majima (MLBoy) <mlboydaisuke@users.noreply.huggingface.co>
- .gitattributes +36 -0
- README.md +132 -0
- config.json +7 -0
- yolox-s_float32.aimodel/main.hash +0 -0
- yolox-s_float32.aimodel/main.mlirb +3 -0
- yolox-s_float32.aimodel/metadata.json +8 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
yolox-s_float32.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: object-detection
|
| 4 |
+
library_name: coreai
|
| 5 |
+
tags:
|
| 6 |
+
- core-ai
|
| 7 |
+
- coreml
|
| 8 |
+
- object-detection
|
| 9 |
+
- yolox
|
| 10 |
+
- apple
|
| 11 |
+
base_model: Megvii-BaseDetection/YOLOX
|
| 12 |
+
base_model_relation: quantized
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# YOLOX-S — Core AI
|
| 16 |
+
|
| 17 |
+
[YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) (Megvii, Apache-2.0) converted to
|
| 18 |
+
Apple **Core AI** (`.aimodel`) — a single-stage **anchor-free** object detector running as
|
| 19 |
+
one static graph on every Apple compute unit (Mac GPU / iPhone GPU / Neural Engine). Part
|
| 20 |
+
of the [Core AI model zoo](https://github.com/john-rocky/coreai-model-zoo)
|
| 21 |
+
([model card](https://github.com/john-rocky/coreai-model-zoo/blob/main/zoo/yolox.md)).
|
| 22 |
+
|
| 23 |
+
The **dense-detector** counterpart to
|
| 24 |
+
[RF-DETR-CoreAI](https://huggingface.co/mlboydaisuke/RF-DETR-CoreAI): where the DETR family
|
| 25 |
+
needs no NMS, YOLOX is the classic `score = obj · cls` + **per-class NMS** pipeline.
|
| 26 |
+
|
| 27 |
+
<!-- gen-cards:use-it begin id=yolox-s (managed by scripts/gen-cards — edit cards.json / QuickStart.swift, not this block) -->
|
| 28 |
+
## Use it
|
| 29 |
+
|
| 30 |
+
⚡ **One line** — run the kit's task op on this model
|
| 31 |
+
(`import CoreAIOps`; no session, no model plumbing, downloads on first use):
|
| 32 |
+
|
| 33 |
+
```swift
|
| 34 |
+
let boxes = try await CoreAI.detect(inImageAt: url, options: .model("yolox-s"))
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Every op, one shape — [Cookbook](https://github.com/john-rocky/coreai-kit/blob/main/docs/COOKBOOK.md).
|
| 38 |
+
|
| 39 |
+
▶️ **Run it (source)** — the [DetectCamera runner](https://github.com/john-rocky/coreai-kit/tree/main/Examples/DetectCamera)
|
| 40 |
+
(real-time object detection on the zero-copy camera path):
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
git clone https://github.com/john-rocky/coreai-kit
|
| 44 |
+
open coreai-kit/Examples/DetectCamera/DetectCamera.xcodeproj
|
| 45 |
+
# → Run, then pick "YOLOX" in the model picker
|
| 46 |
+
|
| 47 |
+
# agents / headless (macOS):
|
| 48 |
+
cd coreai-kit/Examples/DetectCamera
|
| 49 |
+
swift run detect-cli --model yolox-s --image Resources/gate_image.jpg
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
💻 **Build with it** — complete; the glue is kit API, copy-paste runs:
|
| 53 |
+
|
| 54 |
+
```swift
|
| 55 |
+
import CoreAIKitVision
|
| 56 |
+
|
| 57 |
+
let detector = try await KitDetector(catalog: "yolox-s")
|
| 58 |
+
let image = try ImageFile.load(imageURL) // any image file → CGImage + EXIF orientation
|
| 59 |
+
let detections = try await detector.detect(in: image.cgImage)
|
| 60 |
+
// detections: [Detection] — label, score, normalized box (top-left origin)
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
The take-home is [`Examples/DetectCamera/Sources/QuickStart.swift`](https://github.com/john-rocky/coreai-kit/blob/main/Examples/DetectCamera/Sources/QuickStart.swift)
|
| 64 |
+
— this exact code as one typed function, no UI; the CLI is an argument shell over it, and
|
| 65 |
+
the GUI runs the same detector per camera frame on a zero-copy pixel-buffer fast path.
|
| 66 |
+
YOLOX is a dense detector — `KitDetector` runs the obj·cls threshold + per-class NMS
|
| 67 |
+
host-side; the DETR family needs none. Same `detect(in:)` either way.
|
| 68 |
+
|
| 69 |
+
**Integration checklist**
|
| 70 |
+
|
| 71 |
+
- SPM: `https://github.com/john-rocky/coreai-kit` → product **CoreAIKitVision**
|
| 72 |
+
- Info.plist: `NSCameraUsageDescription` — only for the live camera; the snippet needs none
|
| 73 |
+
- Entitlements: none needed
|
| 74 |
+
- First run downloads the model — 0.0 GB (Mac) / 0.0 GB (iPhone) — then it loads from the
|
| 75 |
+
local cache (Application Support; progress via the `downloadProgress` callback)
|
| 76 |
+
- Measure in Release — Debug is ~3× slower on per-token host work
|
| 77 |
+
<!-- gen-cards:use-it end -->
|
| 78 |
+
|
| 79 |
+
## Bundle
|
| 80 |
+
|
| 81 |
+
- `yolox-s_float32.aimodel` — YOLOX-S, 640² input, 8.97M params, **fp32** (the ship dtype;
|
| 82 |
+
detection has no bandwidth-bound decode loop, so fp16 is no faster on the GPU and only adds
|
| 83 |
+
near-tie noise). 36 MB. Same bundle on macOS and iOS.
|
| 84 |
+
|
| 85 |
+
## Graph contract
|
| 86 |
+
|
| 87 |
+
```
|
| 88 |
+
input "image" [1,3,640,640] f32 BGR, 0-255, letterboxed (pad 114, top-left) — YOLOX-native (no /255, no mean/std)
|
| 89 |
+
output "preds" [1,8400,85] f32 [cx,cy,w,h, obj, cls_0..cls_79]; box DECODED to 640-px, obj/cls SIGMOID-ed (in-graph)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Host post-process: `score = obj · max_class`, threshold, **per-class NMS** (IoU 0.45), then
|
| 93 |
+
un-letterbox the survivors. Anchors A = 80² + 40² + 20² = 8400 (strides 8/16/32).
|
| 94 |
+
|
| 95 |
+
## Parity & speed (measured)
|
| 96 |
+
|
| 97 |
+
- **vs torch fp32:** head cosine **1.000000**, end-to-end detections IoU **1.000** on CPU and GPU.
|
| 98 |
+
- **M4 Max GPU: 4.80 ms / 208 FPS** (median). M4 Max CPU 57 ms.
|
| 99 |
+
- **iPhone 17 Pro** (Release, GPU, live camera): **~22 ms / 35–40 FPS** end-to-end; first-load
|
| 100 |
+
on-device specialization ~2.6 s (no AOT). The on-device gate reproduces the Mac fp32 oracle
|
| 101 |
+
**6/6** (cat 0.96/0.96, remote 0.86/0.86, bed 0.71, couch 0.54).
|
| 102 |
+
|
| 103 |
+
## Use (CoreAIKit)
|
| 104 |
+
|
| 105 |
+
```swift
|
| 106 |
+
import CoreAIKitVision
|
| 107 |
+
let detector = try await YOLOXDetector(model: .yoloxS) // downloads this repo
|
| 108 |
+
let detections = try await detector.detect(in: pixelBuffer, scoreThreshold: 0.3)
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
Live-camera + video reference app: **DetectCamera** in
|
| 112 |
+
[coreai-kit](https://github.com/john-rocky/coreai-kit).
|
| 113 |
+
|
| 114 |
+
## Convert it yourself
|
| 115 |
+
|
| 116 |
+
[`conversion/export_yolox.py`](https://github.com/john-rocky/coreai-model-zoo/blob/main/conversion/export_yolox.py)
|
| 117 |
+
— `--variant s --yolox-repo <YOLOX checkout> --weights yolox_s.pth`, gated end-to-end with
|
| 118 |
+
`--verify-image <img> --unit {cpu,gpu}`. The script also maps `nano`/`tiny`/`m`/`l`/`x`.
|
| 119 |
+
|
| 120 |
+
## License
|
| 121 |
+
|
| 122 |
+
Apache-2.0 — upstream YOLOX code and COCO-pretrained weights are Apache-2.0.
|
| 123 |
+
|
| 124 |
+
<!-- funnel:v1 -->
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
**More models in this format:** [Core AI Model Zoo](https://huggingface.co/collections/mlboydaisuke/core-ai-model-zoo-6a7ff330f753e8dcae04671a) — 75 models, each with the recipe that produced it.
|
| 129 |
+
|
| 130 |
+
**Want a different model on-device?** [Open a request](https://github.com/john-rocky/on-device-requests) — free, open weights only; the export and its measured numbers get published publicly.
|
| 131 |
+
|
| 132 |
+
<!-- /funnel:v1 -->
|
config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "coreai-aimodel",
|
| 3 |
+
"format": "aimodel",
|
| 4 |
+
"framework": "Apple Core AI (iOS 27 / macOS 27)",
|
| 5 |
+
"repository": "https://github.com/john-rocky/coreai-model-zoo",
|
| 6 |
+
"note": "Converted .aimodel bundles for Apple's Core AI framework. See README.md for the bundle layout and run instructions."
|
| 7 |
+
}
|
yolox-s_float32.aimodel/main.hash
ADDED
|
Binary file (32 Bytes). View file
|
|
|
yolox-s_float32.aimodel/main.mlirb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1533e74f3365b72c087c43ee7dec9f8f8fdacbe42ddb2b5027d60c0083cc6169
|
| 3 |
+
size 36028733
|
yolox-s_float32.aimodel/metadata.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"assetVersion" : "2.0",
|
| 3 |
+
"license" : "Apache-2.0",
|
| 4 |
+
"description" : "YOLOX-s anchor-free single-stage detector (CSPDarknet + PAFPN + decoupled head). Input: BGR 0-255 letterboxed [1,3,S,S]; output preds [1,A,85] = decoded cxcywh pixels + obj + 80 sigmoid class scores. Host does score=obj*cls threshold + per-class NMS. https:\/\/github.com\/Megvii-BaseDetection\/YOLOX",
|
| 5 |
+
"producer" : "coreai-core 1.0.0b2",
|
| 6 |
+
"creationDate" : "20260720T124242Z",
|
| 7 |
+
"author" : "Megvii (YOLOX); Core AI export: coreai-model-zoo"
|
| 8 |
+
}
|