omni_search
omni_search is a Rust SDK for multimodal embedding and similarity search over local ONNX model directories.
Current scope:
- load a flat local model directory with root-level
model_config.json; - compute text embeddings;
- compute image embeddings;
- compare embeddings with cosine similarity;
- manually unload ONNX Runtime sessions.
Supported families:
chinese_clipfg_clipopen_clip
The published crate does not bundle ONNX models or sample images. Point it at your own local assets with OMNI_BUNDLE_DIR and OMNI_SAMPLES_DIR.
Quickstart:
- set
OMNI_BUNDLE_DIRto a local model directory that containsmodel_config.jsonplus flat root-level assets; - set
OMNI_SAMPLES_DIRto a directory containing one or more.jpg,.jpeg,.png,.webp, or.bmpimages; - build SDK instances with
OmniSearch::builder()when you only want to override part of the runtime config and keep the rest at defaults; - run
cargo run --bin omni_search --releaseto scan all images inOMNI_SAMPLES_DIRwith the default query"山"; - run
cargo run --bin omni_search --release -- "海边"to scan all images with a custom query; - run
cargo run --bin omni_search --release -- "海边" 20to print a different top-k; - run
cargo run --bin omni_search --release -- "海边" "/absolute/path/to/query.jpg"to runimage_to_imagewith a specific query image; - set
OMNI_INTRA_THREADS/OMNI_INTER_THREADSto override ONNX Runtime thread counts when benchmarking or tuning; - set
OMNI_FGCLIP_MAX_PATCHESto cap FG-CLIP2 image preprocessing at a smaller bucket without changing the exported model directory; - recommended
OMNI_FGCLIP_MAX_PATCHESvalues are128,256,576,784, or1024; - run
cargo test --test quickstart -- --ignored --nocaptureto execute the smoke test after settingOMNI_TEST_BUNDLE_DIRandOMNI_TEST_SAMPLE_IMAGE.
Legacy migration:
python .\scripts\flatten_bundle_to_flat.py --input .\models\chinese_clip_bundle --mode hardlink
python .\scripts\flatten_bundle_to_flat.py --input .\models\fgclip2_bundle --mode hardlink
Direct exporters:
The exporter scripts live in D:\code\vl-embedding-test and default to writing flat model
directories into D:\code\omni_search\models.
uv run D:\code\vl-embedding-test\export_openclip_flat.py --id timm/MobileCLIP2-S2-OpenCLIP --output D:\code\omni_search\models\mobileclip2 --force
uv run D:\code\vl-embedding-test\export_chinese_clip_flat.py --model-dir D:\models\chinese-clip-vit-base-patch16 --output D:\code\omni_search\models\chinese_clip_flat --force
uv run D:\code\vl-embedding-test\export_fgclip2_flat.py --model-dir D:\models\fg-clip2-base --output D:\code\omni_search\models\fgclip2_flat --force
Builder example:
use ;
let sdk = builder
.from_local_model_dir
.intra_threads
.fgclip_max_patches
.session_policy
.graph_optimization_level
.build?;