Struct burn_core::data::dataset::HuggingfaceDatasetLoader
source · pub struct HuggingfaceDatasetLoader { /* private fields */ }Expand description
Load a dataset from huggingface datasets.
The dataset with all splits is stored in a single sqlite database (see SqliteDataset).
§Example
use burn_dataset::HuggingfaceDatasetLoader;
use burn_dataset::SqliteDataset;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug, Clone)]
struct MnistItemRaw {
pub image_bytes: Vec<u8>,
pub label: usize,
}
let train_ds:SqliteDataset<MnistItemRaw> = HuggingfaceDatasetLoader::new("mnist")
.dataset("train")
.unwrap();Implementations§
source§impl HuggingfaceDatasetLoader
impl HuggingfaceDatasetLoader
sourcepub fn new(name: &str) -> HuggingfaceDatasetLoader
pub fn new(name: &str) -> HuggingfaceDatasetLoader
Create a huggingface dataset loader.
sourcepub fn with_subset(self, subset: &str) -> HuggingfaceDatasetLoader
pub fn with_subset(self, subset: &str) -> HuggingfaceDatasetLoader
Create a huggingface dataset loader for a subset of the dataset.
The subset name must be one of the subsets listed in the dataset page.
If no subset names are listed, then do not use this method.
sourcepub fn with_base_dir(self, base_dir: &str) -> HuggingfaceDatasetLoader
pub fn with_base_dir(self, base_dir: &str) -> HuggingfaceDatasetLoader
Specify a base directory to store the dataset.
If not specified, the dataset will be stored in ~/.cache/burn-dataset.
sourcepub fn with_huggingface_token(
self,
huggingface_token: &str
) -> HuggingfaceDatasetLoader
pub fn with_huggingface_token( self, huggingface_token: &str ) -> HuggingfaceDatasetLoader
Specify a huggingface token to download datasets behind authentication.
You can get a token from tokens settings
sourcepub fn with_huggingface_cache_dir(
self,
huggingface_cache_dir: &str
) -> HuggingfaceDatasetLoader
pub fn with_huggingface_cache_dir( self, huggingface_cache_dir: &str ) -> HuggingfaceDatasetLoader
Specify a huggingface cache directory to store the downloaded datasets.
If not specified, the dataset will be stored in ~/.cache/huggingface/datasets.
sourcepub fn dataset<I>(self, split: &str) -> Result<SqliteDataset<I>, ImporterError>where
I: DeserializeOwned + Clone,
pub fn dataset<I>(self, split: &str) -> Result<SqliteDataset<I>, ImporterError>where
I: DeserializeOwned + Clone,
Load the dataset.
sourcepub fn db_file(self) -> Result<PathBuf, ImporterError>
pub fn db_file(self) -> Result<PathBuf, ImporterError>
Get the path to the sqlite database file.
If the database file does not exist, it will be downloaded and imported.
Auto Trait Implementations§
impl Freeze for HuggingfaceDatasetLoader
impl RefUnwindSafe for HuggingfaceDatasetLoader
impl Send for HuggingfaceDatasetLoader
impl Sync for HuggingfaceDatasetLoader
impl Unpin for HuggingfaceDatasetLoader
impl UnwindSafe for HuggingfaceDatasetLoader
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
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>
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>
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