mlboydaisuke commited on
Commit
cd5d04d
Β·
verified Β·
1 Parent(s): 7778e87

gen-cards: regenerate Use-it block

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -23,6 +23,46 @@ the answer to [apple/coreai-models#14](https://github.com/apple/coreai-models/is
23
  <p align="center"><img src="demo_coco_cats.jpg" width="440" alt="RF-DETR medium on Core AI"></p>
24
 
25
  <!-- gen-cards:use-it begin id=rf-detr (managed by scripts/gen-cards β€” edit cards.json / QuickStart.swift, not this block) -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  <!-- gen-cards:use-it end -->
27
 
28
  ## Files
 
23
  <p align="center"><img src="demo_coco_cats.jpg" width="440" alt="RF-DETR medium on Core AI"></p>
24
 
25
  <!-- gen-cards:use-it begin id=rf-detr (managed by scripts/gen-cards β€” edit cards.json / QuickStart.swift, not this block) -->
26
+ ## Use it
27
+
28
+ ▢️ **Run it (source)** β€” the [DetectCamera runner](https://github.com/john-rocky/coreai-kit/tree/main/Examples/DetectCamera)
29
+ (real-time object detection on the zero-copy camera path):
30
+
31
+ ```bash
32
+ git clone https://github.com/john-rocky/coreai-kit
33
+ open coreai-kit/Examples/DetectCamera/DetectCamera.xcodeproj
34
+ # β†’ Run, then pick "Nano" in the model picker
35
+
36
+ # agents / headless (macOS):
37
+ cd coreai-kit/Examples/DetectCamera
38
+ swift run detect-cli --model rf-detr --image Resources/gate_image.jpg
39
+ ```
40
+
41
+ πŸ’» **Build with it** β€” complete; the glue is kit API, copy-paste runs:
42
+
43
+ ```swift
44
+ import CoreAIKitVision
45
+
46
+ let detector = try await ObjectDetector(catalog: "rf-detr")
47
+ let image = try ImageFile.load(imageURL) // any image file β†’ CGImage + EXIF orientation
48
+ let detections = try await detector.detect(in: image.cgImage)
49
+ // detections: [Detection] β€” label, score, normalized box (top-left origin)
50
+ ```
51
+
52
+ The take-home is [`Examples/DetectCamera/Sources/QuickStart.swift`](https://github.com/john-rocky/coreai-kit/blob/main/Examples/DetectCamera/Sources/QuickStart.swift)
53
+ β€” this exact code as one typed function, no UI; the CLI is an argument shell over it, and
54
+ the GUI runs the same detector per camera frame on a zero-copy pixel-buffer fast path.
55
+ Real time? Use `detect(in: CVPixelBuffer)` β€” vImage scales the frame with no CGImage
56
+ round-trip; `CameraFeed` (kit API) streams the buffers.
57
+
58
+ **Integration checklist**
59
+
60
+ - SPM: `https://github.com/john-rocky/coreai-kit` β†’ product **CoreAIKitVision**
61
+ - Info.plist: `NSCameraUsageDescription` β€” only for the live camera; the snippet needs none
62
+ - Entitlements: none needed
63
+ - First run downloads the model β€” 0.1 GB (Mac) / 0.1 GB (iPhone) β€” then it loads from the
64
+ local cache (Application Support; progress via the `downloadProgress` callback)
65
+ - Measure in Release β€” Debug is ~3Γ— slower on per-token host work
66
  <!-- gen-cards:use-it end -->
67
 
68
  ## Files