ImFusion C++ SDK 4.4.0
ImFusion::ML::SampleDataLoader Class Reference

#include <ImFusion/ML/DataLoaders/SampleDataLoader.h>

Extract samples from each item in the nested loader. More...

Inheritance diagram for ImFusion::ML::SampleDataLoader:

Detailed Description

Extract samples from each item in the nested loader.

Public Member Functions

 SampleDataLoader (std::unique_ptr< DataLoader > loader, const std::vector< Operation::Specs > &specs={}, int seed=-1, bool verbose=false)
 Constructs a sampling loader.
 SampleDataLoader (DataLoaderList dataLoaders, const Properties &prop)
 SampleDataLoader (std::unique_ptr< DataLoader > loader, const std::vector< std::shared_ptr< ImageROISampler > > &samplers, std::optional< std::vector< float > > weights, int seed=-1, bool verbose=false)
std::optional< DataItemnext () override
 Advance the loader by one iteration.
std::optional< size_t > size () const override
 Size of the loader, has value only for fixed cardinalities.
void reinit () override
 Re-seeds the samplers and the random choice of the sampler to use.
void configure (const Properties *prop) override
 Configure this object instance by de-serializing the given Properties.
void setRandomSeed (unsigned int seed) override
ML::Status canBePrefetched () const override
 Indicates whether a loader is eligible for prefetching.
Public Member Functions inherited from ImFusion::ML::DataLoader
 DataLoader (std::string name, bool verbose=false)
 Constructor to be used by DataReaders, as they are the first elements in the chain.
 DataLoader (std::string name, std::unique_ptr< DataLoader > loader, bool verbose=false)
 Constructor to be used by all other derived DataLoaders.
 DataLoader (std::string name, DataLoaderList &&dataLoaders, bool verbose=false)
 Constructor to be used by all other derived DataLoaders.
const std::stringname () const
 Name of the loader.
virtual void reset ()
 Reset the loader in order to restart the iteration.
virtual Cardinality cardinality () const
 Cardinality of this specific loader node.
DataLoadersingleUnderlyingLoader () const
 Return a single underlying dataloader Expects there to be only one, returns a nullptr otherwise.
std::unique_ptr< DataLoaderextractDataloader ()
 Return a single underlying dataloader Expects there to be only one, throws an exception otherwise.
DataLoaderList & loaders ()
DataLoaderList const & loaders () const
bool verbose () const
const std::stringlogDomain () const
 Log domain for AdvancedParameter.
Public Member Functions inherited from ImFusion::Configurable
virtual void configuration (Properties *p) const
 Serialize the current object configuration into the given Properties object.
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Additional Inherited Members

Public Attributes inherited from ImFusion::ML::DataLoader
LoaderParam< bool > m_verbose = {"verbose", false, this, ParamRequired::No}
 If enabled, print log messages with extra information like timings.
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
Protected Member Functions inherited from ImFusion::Utils::NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
NotCopyable & operator= (NotCopyable &&) noexcept=default
 NotCopyable (const NotCopyable &)=delete
NotCopyable & operator= (const NotCopyable &)=delete
Protected Attributes inherited from ImFusion::ML::DataLoader
std::string m_name
Cardinality m_cardinality = Cardinality::Fixed
Random::Generator m_randGenerator
DataLoaderList m_dataLoaders
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Constructor & Destructor Documentation

◆ SampleDataLoader()

ImFusion::ML::SampleDataLoader::SampleDataLoader ( std::unique_ptr< DataLoader > loader,
const std::vector< Operation::Specs > & specs = {},
int seed = -1,
bool verbose = false )
explicit

Constructs a sampling loader.

Parameters
loaderprevious loader
specsspecifications for the sampling pipeline
seedrandom seed for the sampler selection
verboseprints more information if set to true

Member Function Documentation

◆ next()

std::optional< DataItem > ImFusion::ML::SampleDataLoader::next ( )
overridevirtual

Advance the loader by one iteration.

The function must pull an item from the underlying node, process it and return it. If the underlyng loader is exhausted, returns an empty optional.

Implements ImFusion::ML::DataLoader.

◆ size()

std::optional< size_t > ImFusion::ML::SampleDataLoader::size ( ) const
overridevirtual

Size of the loader, has value only for fixed cardinalities.

Implements ImFusion::ML::DataLoader.

◆ reinit()

void ImFusion::ML::SampleDataLoader::reinit ( )
overridevirtual

Re-seeds the samplers and the random choice of the sampler to use.

Reimplemented from ImFusion::ML::DataLoader.

◆ configure()

void ImFusion::ML::SampleDataLoader::configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from ImFusion::ML::DataLoader.

◆ setRandomSeed()

void ImFusion::ML::SampleDataLoader::setRandomSeed ( unsigned int seed)
overridevirtual

Reimplemented from ImFusion::ML::DataLoader.

◆ canBePrefetched()

ML::Status ImFusion::ML::SampleDataLoader::canBePrefetched ( ) const
overridevirtual

Indicates whether a loader is eligible for prefetching.

Typically, a loader can be prefetched if its code can be executed on any thread. However, if the code to be executed in the prefetcher requires the main thread or acquires state that cannot be released by other threads (such as the Python Global Interpreter Lock), this function must return an error code and a message explaining why.

Returns: A status object indicating whether the loader can be prefetched (OK) or not (error code).

Reimplemented from ImFusion::ML::DataLoader.


The documentation for this class was generated from the following file:
  • ImFusion/ML/DataLoaders/SampleDataLoader.h
Search Tab / S to search, Esc to close