Skip to main content

ModelRunner

Trait ModelRunner 

Source
pub trait ModelRunner {
    // Required methods
    fn platform(&self) -> &str;
    fn model(&self, task: TaskKind) -> Option<(ModelId, ModelVersion)>;
    fn embed_image(
        &self,
        task: TaskKind,
        frames: &[Frame<'_>],
    ) -> Result<Vec<Embedding>, RunnerError>;
    fn embed_text(&self, texts: &[&str]) -> Result<Vec<Embedding>, RunnerError>;
    fn detect(
        &self,
        task: TaskKind,
        frames: &[Frame<'_>],
    ) -> Result<Vec<Vec<Detection>>, RunnerError>;
}
Expand description

The inference seam every consumer routes through. Implemented by real per-platform runners (behind the inference feature) and by FixtureRunner for tests.

Required Methods§

Source

fn platform(&self) -> &str

The platform partition tag for this runner’s outputs (incomparable across platforms).

Source

fn model(&self, task: TaskKind) -> Option<(ModelId, ModelVersion)>

The (model_id, model_version) this runner produces for task, if it serves it. Must equal the registry’s canonical row for the output to be accepted by the index.

Source

fn embed_image( &self, task: TaskKind, frames: &[Frame<'_>], ) -> Result<Vec<Embedding>, RunnerError>

Embed images for an embedding task (SemanticSearch, FaceRecognition). One vector per frame, in order.

Source

fn embed_text(&self, texts: &[&str]) -> Result<Vec<Embedding>, RunnerError>

Embed text into the semantic-search space — for natural-language queries and the zero-shot tagging that reuses the semantic embedder.

Source

fn detect( &self, task: TaskKind, frames: &[Frame<'_>], ) -> Result<Vec<Vec<Detection>>, RunnerError>

Detect objects / faces for a detection task (ObjectDetection, FaceDetection). One list per frame, in order.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§