Jup33QE commited on
Commit
cdc55fe
·
verified ·
1 Parent(s): 8adda95

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - coreai
5
+ - depth-estimation
6
+ - apple
7
+ - macos27
8
+ library_name: coreai
9
+ ---
10
+
11
+ # DA3-LARGE · CoreAI (.aimodel)
12
+
13
+ [Depth Anything 3 (DA3-LARGE)](https://huggingface.co/depth-anything/DA3-LARGE) any-view depth model (ViT-L backbone), converted to Apple's **CoreAI** `.aimodel` format (macOS 27 / iOS 27+, device only — no simulator). Single-image input (N=1).
14
+
15
+ Converted with `coreai_torch 0.4.2` / `torch 2.14` via `torch.export → run_decompositions → TorchConverter → optimize → save_asset`. Two precision builds: **fp32** (1.35 GB) and **fp16** (677.8 MB, half-precision compute with fp32 IO).
16
+
17
+ ## IO contract
18
+
19
+ - Function: `main`
20
+ - Input: `image` — float32 `[1, 3, 504, 504]`, ImageNet-normalized planar RGB (normalization is caller-side)
21
+ - Output: `depth` float32 `[504, 504]` (relative depth; any-view head, no sky output)
22
+
23
+ ## Validation (vs PyTorch fp32 reference, fixed-seed golden input)
24
+
25
+ | Build | max abs err | median rel err | load (cold) | p50 latency (30f) |
26
+ |---|---|---|---|---|
27
+ | fp32 | **8.35e-07** | 1.94e-07 | 1.73 s | 116.9 ms |
28
+ | fp16 | **6.81e-04** | 1.54e-04 | 1.21 s | 39.1 ms |
29
+
30
+ - Export pipeline self-checks: torch.export vs wrapper = 0.0; decomposed graph vs wrapper ≤ 4.9e-04 (fp16)
31
+ - Zero missing operators (39 aten op kinds / 2391 nodes accepted by coreai_torch)
32
+ - Model config: HF snapshot ships no `config.json`; conversion uses the `da3-large.yaml` registry config from the DA3 source tree (weights load with unexpected=0)
33
+ - Any-view RoPE `max_position` is fixed to a static constant (37) at export time — numerically identical, verified eager max|err| = 0
34
+
35
+ ## Usage (Swift)
36
+
37
+ ```swift
38
+ import CoreAI
39
+
40
+ let model = try await AIModel(
41
+ contentsOf: url,
42
+ options: SpecializationOptions(preferredComputeUnitKind: .neuralEngine) // or .gpu / .default
43
+ )
44
+ guard let f = try model.loadFunction(named: "main") else { … }
45
+ let input = NDArray(scalars: pixels, shape: [1, 3, 504, 504])
46
+ var outputs = try await f.run(inputs: ["image": input])
47
+ let depth = outputs.remove("depth")?.ndArray
48
+ ```
49
+
50
+ `preferredComputeUnitKind` is a *preference*: with the fp32 build, `auto` / `.gpu` / `.neuralEngine` land within noise (the model runs on GPU). The **fp16** build is ~3× faster (39.1 ms vs 116.9 ms p50) and is the one that can actually benefit from ANE.
51
+
52
+ ## Files
53
+
54
+ - `da3large-fp32.aimodel/` — fp32 bundle (`main.mlirb` + `main.hash` + `metadata.json`)
55
+ - `da3large-fp16.aimodel/` — fp16 bundle
56
+ - `recipe.toml` — full conversion recipe (sources, versions, validation gates)