pub struct ModelHub { /* private fields */ }Expand description
Model hub for downloading and caching pretrained weights.
Implementations§
Source§impl ModelHub
impl ModelHub
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new hub with the default cache directory and built-in registry of known pretrained models.
Sourcepub fn registry(&self) -> &HashMap<String, HubEntry>
pub fn registry(&self) -> &HashMap<String, HubEntry>
Returns a reference to the internal registry.
Sourcepub fn download_if_missing(&self, name: &str) -> Result<PathBuf, ModelError>
pub fn download_if_missing(&self, name: &str) -> Result<PathBuf, ModelError>
Ensures the weight file for name is present in the local cache,
downloading it via curl if necessary.
Returns the path to the cached file on success.
Sourcepub fn load_weights(
&self,
name: &str,
) -> Result<HashMap<String, Tensor>, ModelError>
pub fn load_weights( &self, name: &str, ) -> Result<HashMap<String, Tensor>, ModelError>
Downloads (if needed) and loads all tensors from the safetensors weight file for the given model name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelHub
impl RefUnwindSafe for ModelHub
impl Send for ModelHub
impl Sync for ModelHub
impl Unpin for ModelHub
impl UnsafeUnpin for ModelHub
impl UnwindSafe for ModelHub
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> 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