[−][src]Function rust_bert::resources::download_resource
pub fn download_resource(resource: &Resource) -> Fallible<&PathBuf>
(Download) the resource and return a path to its local path
This function will download remote resource to their local path if they do not exist yet.
Then for both LocalResource
and RemoteResource
, it will the local path to the resource.
For LocalResource
only the resource path is returned.
Arguments
resource
- Pointer to the&Resource
to optionally download and get the local path.
Returns
&PathBuf
Local path for the resource
Example
use rust_bert::resources::{Resource, RemoteResource, download_resource}; let model_resource = Resource::Remote(RemoteResource::from_pretrained( ("distilbert-sst2/model.ot", "https://cdn.huggingface.co/distilbert-base-uncased-finetuned-sst-2-english-rust_model.ot" ) )); let local_path = download_resource(&model_resource);