Appearance
Vision Runtime
This page covers captioning, inspection, face analysis, grounding, segmentation, tracking, pose extraction, optical flow, video depth, single- and multi-view geometry, image-to-3D reconstruction, and OCR.
Public surface
mere.run vision captionmere.run vision inspectmere.run vision face detectmere.run vision face embedmere.run vision face comparemere.run vision face batchmere.run vision groundmere.run vision segmentmere.run vision trackmere.run vision track-livemere.run vision posemere.run vision flowmere.run vision depth-videomere.run vision geometrymere.run vision geometry-multiviewmere.run vision image-to-3dmere.run vision image-to-3d-trellis2mere.run vision image-to-3d-multiviewmere.run vision ocr
Model family
vision-ocr-lightonvision-ground-falcon-perceptionvision-face-buffalo-lvision-segment-sam31vision-geometry-moge2-smallvision-depth-vda-smallvision-depth-vda-small-metricvision-geometry-da3-smallimage-3d-triposrimage-3d-trellis2-4bimage-3d-instantmesh-base
Captioning and inspect flows also depend on vision-language support code in MereRunCore.
Grounding runs natively through the Swift/MLX Falcon Perception stack in MereRunCore.
Segmentation and tracking run natively through the Swift/MLX SAM 3.1 stack in MereRunCore.
Face analysis runs the Buffalo-L detector and ArcFace R50 recognizer locally through ONNX Runtime. The default auto provider uses CPU for this model based on the repository's Apple Silicon parity run; --execution-provider coreml and --execution-provider cpu remain explicit controls.
The detector is useful beyond identity search: it provides face boxes and five-point landmarks for alignment, crops, counts, redaction, face-aware reframing, thumbnail selection, and dataset quality gates. The embedding model also supports verification, unnamed-person clustering, similarity search, representative prototype selection, and identity-outlier review. Neither model claims emotion, demographic attributes, liveness, deepfake detection, or general image understanding.
Current SAM 3.1 scope
vision segmentsupports text prompts plus geometry prompting with boxes and pointsvision tracksupports text, box, and point prompts on the init frame, then propagates tracked objects through later framesvision track-liverecords a camera clip, searches a short warm-up window for seed objects, and then runs the same native tracking path over the saved recording- the managed model package
vision-segment-sam31is the single SAM 3.1 package for segmentation and tracking
Current implementation notes
- still-image text prompting uses the native detector path
- still-image box and point prompting use the native interactive SAM prompt path
- offline video tracking currently uses native prompt propagation built on top of the image segmenter rather than a full SAM memory-bank tracker
- live capture is text-prompt seeded only in the current CLI surface
Fused attention policy
Supported SAM 3.1, LightOn OCR, and selected vision-encoder attention shapes use MLX fused scaled-dot-product attention by default. Unsupported shapes retain their portable implementation. Set MERERUN_FUSED_SDPA=0 for an emergency compatibility fallback or a controlled A/B.
The installed-model gate on 2026-07-11 used release binaries on an M4 Max with 128 GB unified memory. A SAM 3.1 text-prompt segmentation run was about 3% faster (1.36s to 1.32s) and reduced peak footprint by 13.2%; all 11 exported masks were bit-exact, with only negligible score/box deltas. A warm LightOn OCR run improved from 2.87s to 1.97s (1.46x throughput) and reduced peak footprint by 55%, with byte-identical text. Process RSS was effectively flat in both comparisons, so these measurements are not presented as general RSS savings or as guarantees for other models, prompts, or shapes.
Typical workflows
Caption an image
bash
swift run mere.run vision caption ./image.pngFor dataset captioning, use a domain prompt file and focus terms when the generic captioner would miss the training objective:
bash
swift run mere.run vision caption ./cards/*.jpg \
--output-dir ./captions \
--prompt-file ./card-caption-prompt.txt \
--focus "full card border" "printed title text" "visible gag" \
--trigger-token cardstyle \
--temperature 0.1Inspect an image with a question
bash
swift run mere.run vision inspect ./image.png "What objects are visible?"Detect, embed, and compare faces
bash
swift run mere.run model pull vision-face-buffalo-l --accept-model-license
swift run mere.run vision face detect ./group.jpg --json
swift run mere.run vision face embed ./reference.jpg --json
swift run mere.run vision face compare ./reference.jpg ./candidate.jpg --jsondetect --include-embeddings emits one normalized 512-dimensional embedding per detected face. embed selects the largest face by default or accepts --face-index; compare returns cosine similarity. Use the companion mere-face-tools plugin for resumable folder indexing, SQLite search, and review/export workflows.
For folder-scale processing, face batch keeps the detector and embedding sessions warm across many images:
bash
swift run mere.run vision face batch --input-list ./images.txt --jsonl-output ./faces.jsonl--input-list reads one image path per line (positional image paths also work), --jsonl-output writes one durable JSONL record per image instead of stdout, and --fail-fast stops at the first unreadable or invalid image.
Buffalo-L pretrained weights are provided by InsightFace for non-commercial research use. The pull command requires --accept-model-license to acknowledge the upstream restriction and prints the authoritative license URL before the download starts. The weights are not bundled with mere.run.
Segment an image with SAM 3.1
bash
swift run mere.run model pull vision-segment-sam31 --accept-model-license
swift run mere.run vision segment ./image.png --prompt "a person"Ground objects with Falcon Perception
bash
swift run mere.run model pull vision-ground-falcon-perception
swift run mere.run vision ground ./image.png --query "cat" "person in red" \
--mask-output-dir ./masks--query (alias --prompt) accepts one or more grounding expressions in a single run; at least one is required. If --model/-m is omitted, the command resolves the managed vision-ground-falcon-perception package from the local model store; it also accepts a local Falcon Perception model root directory. The annotated image defaults to <stem>_grounded.<ext> (--output/-o overrides it), JSON metadata defaults to <stem>_grounded.json (--json-output overrides it), and --mask-output-dir exports one PNG mask per detection.
Track objects through a video
bash
swift run mere.run model pull vision-segment-sam31 --accept-model-license
swift run mere.run vision track ./clip.mp4 --prompt "a dog" --init-frame 12Track a recorded live camera session
bash
swift run mere.run vision track-live --output ./live.mp4 --prompt "a person"Extract pose landmarks
bash
swift run mere.run vision pose ./person.png \
--json-output ./person-pose.json \
--minimum-confidence 0.2The native pose result contains body, hand, and face subjects. Landmark coordinates use a normalized bottom-left coordinate system and retain per-point confidence for downstream temporal filtering and motion export.
Generate a dense motion pass
bash
swift run mere.run vision flow ./frame-001.png ./frame-002.png \
--output ./frame-001-to-002.flo \
--accuracy highThe two images must have equal dimensions. Output vectors use the Middlebury .flo format and preserve full-resolution 32-bit horizontal and vertical motion components.
Generate temporally consistent video depth
bash
swift run mere.run model pull vision-depth-vda-small
swift run mere.run vision depth-video ./clip.mp4 --output ./clip-depthNative Video Depth Anything Small writes per-frame depth EXRs, preview PNGs, a review MP4, and a depth-sequence manifest JSON into the output directory (default <stem>-depth next to the input). --input-size bounds the longest network edge before aspect-ratio adjustment (default 518) and --max-frames bounds decoded source frames (default 240). The default model is relative depth; --model vision-depth-vda-small-metric switches to the metric variant. --dry-run hashes and decodes the bounded input, verifies media/network limits and the checkpoint, then prints the plan without inference; --json prints the structured result on stdout.
Recover metric geometry from a single image
bash
swift run mere.run model pull vision-geometry-moge2-small
swift run mere.run vision geometry ./photo.jpg --output ./photo-geometryNative MoGe-2 emits metric depth and normal EXRs with preview PNGs, a validity mask, camera intrinsics JSON, a point-cloud PLY, and a manifest (default directory <stem>-geometry). --resolution-level selects quality 0 through 9 (default 9), --token-count overrides the DINO base-token count (1 to 3600), and --max-points caps the PLY point count. --dry-run and --json behave as in depth-video.
Solve multi-view geometry and cameras
bash
swift run mere.run model pull vision-geometry-da3-small
swift run mere.run vision geometry-multiview ./view-01.jpg ./view-02.jpg ./view-03.jpg \
--output ./sceneNative DA3-Small solves relative depth, per-view confidence, and cameras across the ordered views, exporting per-view depth/confidence EXRs and preview PNGs, camera JSON, colored point clouds (PLY and GLB), a Nerfstudio/3DGS initialization handoff, and a scene manifest (default directory <first-stem>-da3-scene). --cameras supplies one calibrated W2C camera per image as JSON; --process-resolution bounds the longest processed side (default 504); --reference-view picks first, middle, saddle-balanced (default), or saddle-similarity-range; --confidence-percentile (default 40) discards low-confidence points and --max-points caps scene exports. --dry-run and --json behave as in depth-video.
Reconstruct a PBR object with TRELLIS.2
Accept the DINOv3 checkpoint license on Hugging Face before the first pull, then run the native 512-resolution pipeline:
bash
swift run mere.run model pull image-3d-trellis2-4b --accept-model-license
swift run mere.run vision image-to-3d-trellis2 ./object.png \
--output ./object-trellis2 \
--seed 42Transparent alpha is required by default. --already-framed explicitly opts an opaque, isolated object into black-background conditioning. The result contains canonical colored OBJ/PLY/GLB meshes and a hashed .pbrvox sidecar that preserves base color, metallic, roughness, and alpha.
Output artifacts
vision ground
- annotated image written to
<stem>_grounded.<ext>unless--outputis provided - JSON metadata written to
<stem>_grounded.jsonunless--json-outputis provided - optional mask PNGs written to
--mask-output-dir
The JSON includes:
schemaVersion- model and input/output paths
- query list
- detections with
query, normalizedxy, normalizedhw, derivedbox, optionalscore, and optionalmaskPath
vision face
detectemits image dimensions, elapsed inference time, face scores, pixel boxes, and five landmarks;--include-embeddingsadds identity vectorsembedemits one selected face and its normalized 512-value embeddingcompareemits the selected face indexes and cosine similaritybatchkeeps the sessions warm and emits one durable JSONL result per image;--include-embeddingsenables recognition/search vectors--jsonkeeps stdout machine-readable;--json-outputwrites the same sorted payload atomically
vision segment
- annotated image written to
<stem>_segmented.<ext>unless--outputis provided - JSON metadata written to
<stem>_segmented.jsonunless--json-outputis provided - optional mask PNGs written to
--mask-output-dir
The JSON includes:
schemaVersion- model and input/output paths
- prompts, threshold, and resolution
- detections with
label,score,box,maskAreaPixels, and optionalobjectID,promptKind,maskPath, andcandidateIndex
vision track and vision track-live
- annotated video written to
<stem>_tracked.mp4forvision track - JSON metadata written to
<stem>_tracked.jsonforvision track vision track-liverequires an explicit output video pathvision track-livedefaults to frame 0 but searches a short warm-up window when that frame yields no seed objects- optional per-frame mask PNGs written under frame-named subdirectories when
--mask-output-diris set onvision track
The tracking JSON includes:
schemaVersion- model and input/output paths
- fps, frame size, init frame, and dropped frame count
- stable tracked object metadata
- per-frame detections with
objectID,label,score,visible,box,maskAreaPixels, and optionalmaskPath
vision pose
- JSON metadata written to
<stem>_pose.jsonunless--json-outputis provided - typed body, hand, and face subjects with stable point names
- normalized coordinates, image dimensions, and confidence values
- no separately installed model package on Apple platforms; inference is owned by the native platform runtime in
MereRunCore
vision flow
- dense full-resolution two-component optical-flow vectors
- standard Middlebury
.flooutput plus typed JSON metadata - selectable native accuracy and magnitude statistics
- explicit equal-dimension validation
OCR
bash
swift run mere.run vision ocr ./page.png --backend lighton
swift run mere.run vision ocr ./page.png --backend infinity --infinity-task doc2mdFor an external Infinity-Parser2 parity eval against an already-running vLLM server:
bash
swift run mere.run vision ocr ./page.png \
--backend infinity \
--infinity-runtime external \
--infinity-api-url http://127.0.0.1:8000/v1/chat/completionsRuntime entrypoints
CLI
Sources/MereRunCLI/Commands/VisionCaptionCommand.swiftSources/MereRunCLI/Commands/VisionInspectCommand.swiftSources/MereRunCLI/Commands/VisionFaceCommand.swiftSources/MereRunCLI/Commands/VisionGroundCommand.swiftSources/MereRunCLI/Commands/VisionSegmentCommand.swiftSources/MereRunCLI/Commands/VisionTrackCommand.swiftSources/MereRunCLI/Commands/VisionTrackLiveCommand.swiftSources/MereRunCLI/Commands/VisionPoseCommand.swiftSources/MereRunCLI/Commands/VisionFlowCommand.swiftSources/MereRunCLI/Commands/VisionDepthVideoCommand.swiftSources/MereRunCLI/Commands/VisionGeometryCommand.swiftSources/MereRunCLI/Commands/VisionGeometryMultiViewCommand.swiftSources/MereRunCLI/Commands/VisionOCRCommand.swift
Pose runtime
Sources/MereRunCore/Pose/NativePoseDetector.swift
Optical-flow runtime
Sources/MereRunCore/OpticalFlow/NativeOpticalFlowGenerator.swift
OCR runtime
Sources/MereRunCore/LightOnOCR/LightOnOCRGenerator.swiftSources/MereRunCore/LightOnOCR/LightOnOCRGenerator+Loading.swiftSources/MereRunCore/LightOnOCR/LightOnOCRGenerator+Inference.swiftSources/MereRunCore/LightOnOCR/LightOnOCRSupport.swiftSources/MereRunCore/Q35/Q35Generator.swiftSources/MereRunCore/Q35/Q35Model.swiftSources/MereRunCore/Q35/Q35VisionTower.swift
Vision-language support
Sources/MereRunCore/VLM/Sources/MereRunCore/QwenVLCaptioner.swiftSources/MereRunCore/Qwen25VLEncoder.swiftSources/MereRunCore/QwenVisionAttention.swift
Falcon grounding runtime
Sources/MereRunCore/FalconPerception/FalconPerceptionConfig.swiftSources/MereRunCore/FalconPerception/FalconPerceptionResources.swiftSources/MereRunCore/FalconPerception/FalconPerceptionTokenizer.swiftSources/MereRunCore/FalconPerception/FalconPerceptionProcessor.swiftSources/MereRunCore/FalconPerception/FalconPerceptionModel.swiftSources/MereRunCore/FalconPerception/FalconPerceptionAnyUp.swiftSources/MereRunCore/FalconPerception/FalconPerceptionGrounder.swift
SAM 3.1 runtime
Sources/MereRunCore/SAM3/SAM31Config.swiftSources/MereRunCore/SAM3/SAM31Resources.swiftSources/MereRunCore/SAM3/SAM31Tokenizer.swiftSources/MereRunCore/SAM3/SAM31Model.swiftSources/MereRunCore/SAM3/SAM31InteractiveSAM.swiftSources/MereRunCore/SAM3/SAM31Prompts.swiftSources/MereRunCore/SAM3/SAM31ImageSegmenter.swiftSources/MereRunCore/SAM3/SAM31VideoIO.swiftSources/MereRunCore/SAM3/SAM31VideoTracker.swiftSources/MereRunCore/SAM3/SAM31CameraCapture.swift
How the OCR path works
- the CLI resolves the OCR model
- the OCR runtime loads the required components
- the input image is normalized into the expected tensor form
- OCR inference runs
- text is emitted without internal bring-up logs on stdout
LightOnOCR uses the dedicated LightOn runtime and remains the default vision ocr backend. Native Infinity-Parser2 uses the Q35 text runtime plus the Qwen-family vision tower, with vision-ocr-infinity-flash as the default Infinity model, vision-ocr-infinity-pro-int8 as the quality-focused Pro eval option, and vision-ocr-infinity-pro as the full BF16 heavyweight compatibility target.
GLM-OCR remains an external CLI adapter that shells out to glmocr. Infinity can also run as an external parity adapter through --infinity-runtime external, which shells out to the parser executable from infinity_parser2 and can target an upstream Transformers, vLLM engine, or vLLM server run.
How segmentation and tracking work
- the CLI resolves
vision-segment-sam31from the model store or uses the local root passed with--model - the native SAM 3.1 runtime validates the root, loads tokenizer/config/weights, and preprocesses the input image or video frames
- still-image text prompts run the detector once, then text + DETR + mask decode per prompt
- geometry prompts use the interactive SAM path, and video tracking reuses those prompts frame to frame after the seed frame
- native postprocessing applies thresholding, mask resize, score ordering, NMS, and optional mask export
- the runtime writes annotated media plus structured JSON metadata
How grounding works
- the CLI resolves
vision-ground-falcon-perceptionfrom the model store or uses the local root passed with--model - the native Falcon runtime validates the root, loads config/tokenizer/weights, and preprocesses the image plus text query
- the model autoregressively emits grounded detections, including coordinate and size tokens, and decodes optional segmentation masks
- native postprocessing derives normalized centers, sizes, bounding boxes, and optional exported mask artifacts
- the runtime writes an annotated image plus structured JSON metadata designed for downstream agent use
How caption and inspect differ
captionis a direct descriptive taskinspectis a question-driven vision-language path
They share some of the same underlying vision support code, but they are presented as separate public tasks because the user intent differs.