pub struct WebDataset { /* private fields */ }Expand description
A dataset read from WebDataset-format shards.
Build one with WebDataset::builder, then append stages with the methods
below. Anything that changes the item type — batching, projecting to tuples
— happens on iter using the adapters in
filters.
Implementations§
Source§impl WebDataset
impl WebDataset
Sourcepub fn builder(urls: impl AsRef<str>) -> WebDatasetBuilder
pub fn builder(urls: impl AsRef<str>) -> WebDatasetBuilder
Start building a dataset from brace patterns or a ::-separated list.
Sourcepub fn builder_from<S: AsRef<str>>(
patterns: impl IntoIterator<Item = S>,
) -> WebDatasetBuilder
pub fn builder_from<S: AsRef<str>>( patterns: impl IntoIterator<Item = S>, ) -> WebDatasetBuilder
Start building a dataset from several patterns.
Sourcepub fn builder_verbatim<S: Into<String>>(
urls: impl IntoIterator<Item = S>,
) -> WebDatasetBuilder
pub fn builder_verbatim<S: Into<String>>( urls: impl IntoIterator<Item = S>, ) -> WebDatasetBuilder
Start building a dataset from URLs that need no expansion.
Sourcepub fn builder_from_yaml(spec: impl Into<String>) -> WebDatasetBuilder
Available on crate feature yaml only.
pub fn builder_from_yaml(spec: impl Into<String>) -> WebDatasetBuilder
yaml only.Start building a dataset from a YAML multi-source specification.
Sourcepub fn open(urls: impl AsRef<str>) -> Result<WebDataset>
pub fn open(urls: impl AsRef<str>) -> Result<WebDataset>
Build a dataset from urls with the default settings.
Shards are not shuffled and the dataset refuses to run distributed; use
builder to change either.
Sourcepub fn from_pipeline(pipeline: DataPipeline) -> WebDataset
pub fn from_pipeline(pipeline: DataPipeline) -> WebDataset
Wrap an already assembled pipeline.
Sourcepub fn pipeline(&self) -> &DataPipeline
pub fn pipeline(&self) -> &DataPipeline
The underlying pipeline.
Sourcepub fn into_pipeline(self) -> DataPipeline
pub fn into_pipeline(self) -> DataPipeline
Take the underlying pipeline.
Sourcepub fn with(self, stage: impl Stage + 'static) -> WebDataset
pub fn with(self, stage: impl Stage + 'static) -> WebDataset
Append an arbitrary stage.
Sourcepub fn shuffle(self, bufsize: usize) -> WebDataset
pub fn shuffle(self, bufsize: usize) -> WebDataset
Shuffle samples through a buffer of bufsize.
Sourcepub fn decode(self, decoder: Decoder) -> WebDataset
pub fn decode(self, decoder: Decoder) -> WebDataset
Decode every field of every sample.
Sourcepub fn decode_basic(self) -> WebDataset
pub fn decode_basic(self) -> WebDataset
Decode with the default handler chain.
Sourcepub fn decode_images(self, imagespec: &str) -> Result<WebDataset>
Available on crate feature image only.
pub fn decode_images(self, imagespec: &str) -> Result<WebDataset>
image only.Decode images with the given imagespec, plus the default handlers.
Sourcepub fn map(
self,
f: impl Fn(Sample) -> Result<Option<Sample>> + Send + Sync + 'static,
) -> WebDataset
pub fn map( self, f: impl Fn(Sample) -> Result<Option<Sample>> + Send + Sync + 'static, ) -> WebDataset
Apply a function to each sample; returning None drops it.
Sourcepub fn map_field(
self,
field: impl Into<String>,
f: impl Fn(Value) -> Result<Value> + Send + Sync + 'static,
) -> WebDataset
pub fn map_field( self, field: impl Into<String>, f: impl Fn(Value) -> Result<Value> + Send + Sync + 'static, ) -> WebDataset
Apply a function to one field of each sample.
Sourcepub fn select(
self,
predicate: impl Fn(&Sample) -> bool + Send + Sync + 'static,
) -> WebDataset
pub fn select( self, predicate: impl Fn(&Sample) -> bool + Send + Sync + 'static, ) -> WebDataset
Keep the samples a predicate accepts.
Sourcepub fn rename<A: Into<String>, B: Into<String>>(
self,
renames: impl IntoIterator<Item = (A, B)>,
) -> WebDataset
pub fn rename<A: Into<String>, B: Into<String>>( self, renames: impl IntoIterator<Item = (A, B)>, ) -> WebDataset
Rename fields, resolving each source from a ;-separated alternation.
Sourcepub fn slice(self, start: usize, count: Option<usize>) -> WebDataset
pub fn slice(self, start: usize, count: Option<usize>) -> WebDataset
Take count samples starting at start.
Sourcepub fn with_epoch(self, nsamples: usize) -> WebDataset
pub fn with_epoch(self, nsamples: usize) -> WebDataset
Make an epoch exactly nsamples long, replaying the source as needed.
Each DataLoader worker runs its own copy of the pipeline, so the
limit applies per worker: with four workers, with_epoch(1000) yields
4000 samples per epoch. Divide by the worker count if you want the
total to match.
Sourcepub fn repeat(self, epochs: usize) -> WebDataset
pub fn repeat(self, epochs: usize) -> WebDataset
Replay the dataset epochs times.
Sourcepub fn take(self, nsamples: usize) -> WebDataset
pub fn take(self, nsamples: usize) -> WebDataset
Stop after nsamples in total.
Sourcepub fn iter(&self) -> SampleStream
pub fn iter(&self) -> SampleStream
Start an epoch.
Sourcepub fn iter_ok(&self) -> impl Iterator<Item = Sample> + Send
pub fn iter_ok(&self) -> impl Iterator<Item = Sample> + Send
Start an epoch, discarding failures.
Sourcepub fn loader(&self) -> DataLoader
pub fn loader(&self) -> DataLoader
Read this dataset with a pool of worker threads.
Trait Implementations§
Source§impl Clone for WebDataset
impl Clone for WebDataset
Source§fn clone(&self) -> WebDataset
fn clone(&self) -> WebDataset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebDataset
impl Debug for WebDataset
Source§impl IntoIterator for &WebDataset
impl IntoIterator for &WebDataset
Auto Trait Implementations§
impl !RefUnwindSafe for WebDataset
impl !UnwindSafe for WebDataset
impl Freeze for WebDataset
impl Send for WebDataset
impl Sync for WebDataset
impl Unpin for WebDataset
impl UnsafeUnpin for WebDataset
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomValue for T
impl<T> CustomValue for T
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