Skip to main content

MediaEncoder

Struct MediaEncoder 

Source
pub struct MediaEncoder {
    pub text: EmbeddingGemma2,
    pub proc: VisionProcessor,
    pub ids: SpecialIds,
    /* private fields */
}
Expand description

The text encoder with the vision and audio towers beside it (each loaded on first use).

Fields§

§text: EmbeddingGemma2§proc: VisionProcessor§ids: SpecialIds

Implementations§

Source§

impl MediaEncoder

Source

pub fn load( model: &Arc<CmfModel>, pool: Option<Arc<Pool>>, ) -> Result<Self, String>

Source

pub fn has_vision(&self) -> bool

Does the file carry the vision tower?

Source

pub fn vision(&self) -> Result<&VisionTower, String>

The vision tower, loaded on first use (~0.7 GB of f32 weights).

Source

pub fn warm_vision(&self) -> Result<(), String>

Load the tower now (a server does it at startup).

Source

pub fn has_audio(&self) -> bool

Does the file carry the audio tower?

Source

pub fn audio(&self) -> Result<&AudioTower, String>

The audio tower, loaded on first use (~1.2 GB of f32 weights).

Source

pub fn warm_audio(&self) -> Result<(), String>

Load the audio tower now.

Source

pub fn warm_for(&self, inputs: &[MixedInput]) -> Result<(), String>

Load the towers the inputs need (their one-time load stays out of a timed forward).

Source

pub fn prepare_image( &self, img: &RgbFrame, budget: Option<usize>, ) -> Result<Media, String>

An image at budget soft tokens (None: the processor’s default).

Source

pub fn prepare_frames( &self, frames: &[RgbFrame], budget: Option<usize>, ) -> Result<Media, String>

Sampled video frames at budget soft tokens a frame.

Source

pub fn input_ids(&self, input: &MixedInput) -> Result<Vec<u32>, String>

Token ids of one input, every placeholder expanded.

Source

pub fn layout( &self, input: &MixedInput, ) -> Result<(Vec<u32>, Placement), String>

Token ids of one input with every placeholder expanded, and where its soft tokens come from, in sequence order.

Source

pub fn embed(&self, inputs: &[MixedInput]) -> Result<Vec<Vec<f32>>, String>

Embed inputs: unit-length vectors of the model’s width, in order.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more