pub struct VisionProcessor {
pub patch: usize,
pub pool_k: usize,
pub image_budget: usize,
pub video_budget: usize,
pub video_fps: f64,
pub max_frames: usize,
pub overflow_truncate: bool,
}Expand description
The processor settings (processor_config.json).
Fields§
§patch: usize§pool_k: usize§image_budget: usizesoft tokens per image (image_processor.max_soft_tokens)
video_budget: usizesoft tokens per video frame (video_processor.max_soft_tokens)
video_fps: f64frames sampled per second of video
max_frames: usizesampled frames are cut to this many, evenly (overflow_strategy)
overflow_truncate: booluniform (default) or truncate
Implementations§
Source§impl VisionProcessor
impl VisionProcessor
Sourcepub fn from_config(cfg: &Value) -> Self
pub fn from_config(cfg: &Value) -> Self
From processor_config.json (missing fields keep the defaults).
Source§impl VisionProcessor
impl VisionProcessor
Sourcepub fn resized_size(
&self,
w: usize,
h: usize,
budget: usize,
) -> Result<(usize, usize), String>
pub fn resized_size( &self, w: usize, h: usize, budget: usize, ) -> Result<(usize, usize), String>
The size an image of w × h is resized to at budget soft tokens.
Sourcepub fn prepare_image(
&self,
img: &RgbFrame,
budget: usize,
) -> Result<VisionInput, String>
pub fn prepare_image( &self, img: &RgbFrame, budget: usize, ) -> Result<VisionInput, String>
Resize (when the size changes) and patchify one image.
Sourcepub fn prepare_frames(
&self,
frames: &[RgbFrame],
budget: usize,
) -> Result<Vec<VisionInput>, String>
pub fn prepare_frames( &self, frames: &[RgbFrame], budget: usize, ) -> Result<Vec<VisionInput>, String>
Video frames (already sampled, one size): each resized to the size
frame 0 takes at budget, then patchified.
Sourcepub fn sample_indices(&self, total: usize, src_fps: Option<f64>) -> Vec<usize>
pub fn sample_indices(&self, total: usize, src_fps: Option<f64>) -> Vec<usize>
The frames of a total-frame video at src_fps the processor keeps:
int(i · src_fps / fps) for i < max(1, int(total / src_fps · fps)),
then cut to max_frames (evenly, np.linspace(..., dtype=int), or
the first ones under truncate). src_fps = None (frames with no
rate) keeps every frame and applies only the cap.