Views
No views yet
Mirror ofmlboydaisuke/Depth-Anything-3-CoreAI— the canonical repo (CoreAI Model Zoo). Updates land there first.
.aimodel. A conversion of ByteDance's
Depth Anything 3
(depth-anything/DA3-SMALL /
DA3-BASE, Apache-2.0): a DINOv2 ViT backbone +
DPT-style head. Drop in an RGB image, get a depth map (and a confidence map). No NMS, no sampling —
host post-processing is just a colormap.1git clone https://github.com/john-rocky/coreai-kit
2open coreai-kit/Examples/DepthCamera/DepthCamera.xcodeproj
3# → Run, then pick "Depth Anything 3 Small" in the model picker
4
5# agents / headless (macOS):
6cd coreai-kit/Examples/DepthCamera
7swift run depth-cli --model depth-anything-3-small --image sample.jpg --output depth.png1import CoreAIKitVision
2
3let estimator = try await DepthEstimator(catalog: "depth-anything-3-small")
4let image = try ImageFile.load(imageURL) // any image file → CGImage + EXIF orientation
5let depth = try await estimator.estimateDepth(for: image.cgImage)
6// depth: DepthMap — .cgImage() renders it, .values are the raw floatsExamples/DepthCamera/Sources/QuickStart.swift
— this exact code as one typed function, no UI; the CLI is an argument shell over it, and
the GUI runs the same estimator on every camera frame (CameraFeed, ~10 lines).
Live camera? CameraFeed (kit API) streams frames — feed each one to
estimateDepth(for:); the camera permission prompt is your app's own chrome.https://github.com/john-rocky/coreai-kit → product CoreAIKitVisionNSCameraUsageDescription — only for the live camera; the snippet needs nonedownloadProgress callback)| dir | variant | params | dtype | size | M4 Max GPU |
|---|---|---|---|---|---|
small/da3-small_float16.aimodel | ViT-S | 34.3M | fp16 | 54 MB | 65.7 FPS |
small/da3-small_float32.aimodel | ViT-S | 34.3M | fp32 | 105 MB | 56.5 FPS |
base/da3-base_float16.aimodel | ViT-B | 135.4M | fp16 | 202 MB | 26.5 FPS |
base/da3-base_float32.aimodel | ViT-B | 135.4M | fp32 | 402 MB | 23.0 FPS |
small · fp16 is the on-device hero — 54 MB, 65 FPS at 504² on an M4 Max, comfortably real-time on
iPhone-class GPUs. Each .aimodel is a directory bundle (main.mlirb + metadata.json).input : image [1, 3, 504, 504] RGB, raw [0, 1] (ImageNet normalization is folded into the graph)
output: depth [1, 504, 504] relative depth (exp-activated; larger = nearer)
depth_conf [1, 504, 504] confidenceINTER_AREA), feed raw [0, 1], run, then resize
the depth map back to the original H × W. For display, the DA3 convention is inverse-depth →
percentile 2–98 normalize → Spectral colormap.1import coreai.runtime as rt, numpy as np
2from PIL import Image
3
4m = await rt.AIModel.load("small/da3-small_float16.aimodel",
5 rt.SpecializationOptions.from_preferred_compute_unit_kind(rt.ComputeUnitKind.gpu()))
6fn = m.load_function("main")
7
8img = np.asarray(Image.open("photo.jpg").convert("RGB").resize((504, 504)))
9x = (img.astype(np.float16) / 255.0).transpose(2, 0, 1)[None] # raw [0,1], NCHW
10depth = (await fn({"image": rt.NDArray(x)}))["depth"].numpy().reshape(504, 504)zoo/depth-anything-3.md