pub struct ClipModelWrapper { /* private fields */ }Expand description
Unified CLIP model wrapper.
Implementations§
Source§impl ClipModelWrapper
impl ClipModelWrapper
Sourcepub fn new_openai(
vb: VarBuilder<'_>,
config: &ClipConfig,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn new_openai( vb: VarBuilder<'_>, config: &ClipConfig, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load OpenAI CLIP from VarBuilder.
Sourcepub fn new_chinese(
vb: VarBuilder<'_>,
config: &ChineseClipConfig,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn new_chinese( vb: VarBuilder<'_>, config: &ChineseClipConfig, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load Chinese-CLIP from VarBuilder.
Sourcepub fn new_siglip(
vb: VarBuilder<'_>,
config: &Config,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn new_siglip( vb: VarBuilder<'_>, config: &Config, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load SigLIP from VarBuilder.
Sourcepub fn from_config_json(
vb: VarBuilder<'_>,
config_path: &Path,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn from_config_json( vb: VarBuilder<'_>, config_path: &Path, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load from config.json — auto-detects CLIP variant.
candle’s ClipConfig doesn’t derive Deserialize, so we use preset configs and override image_size / projection_dim from the JSON when present.
Sourcepub fn get_text_features(&self, input_ids: &Tensor) -> Result<Tensor>
pub fn get_text_features(&self, input_ids: &Tensor) -> Result<Tensor>
Get text embedding (L2-normalized).
Sourcepub fn get_image_features(&self, pixel_values: &Tensor) -> Result<Tensor>
pub fn get_image_features(&self, pixel_values: &Tensor) -> Result<Tensor>
Get image embedding (L2-normalized).
pub fn device(&self) -> &CandleDevice
pub fn dtype(&self) -> DType
pub fn image_size(&self) -> usize
pub fn projection_dim(&self) -> usize
Auto Trait Implementations§
impl !Freeze for ClipModelWrapper
impl !RefUnwindSafe for ClipModelWrapper
impl Send for ClipModelWrapper
impl Sync for ClipModelWrapper
impl Unpin for ClipModelWrapper
impl UnsafeUnpin for ClipModelWrapper
impl !UnwindSafe for ClipModelWrapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more