MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.db.image.ImageSet2 Class Reference

[V2 Image Database] The ImageSet2 manages the data source data including the master list of images, and the master indexes that describe the data source layout (e.g. labels, boosts, etc). More...

Inheritance diagram for MyCaffe.db.image.ImageSet2:
MyCaffe.db.image.ImageSetBase

Public Types

enum  TYPE { TRAIN , TEST }
 Defines the type of image set. More...
 

Public Member Functions

 ImageSet2 (TYPE type, Log log, DatasetFactory factory, SourceDescriptor src, DB_LOAD_METHOD loadMethod, CryptoRandom random, WaitHandle[] rgAbort)
 The ImageSet2 constructor. More...
 
QueryState Initialize (bool bSilentLoad, bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, int nMaxLoadCount=0, bool bVerify=false)
 Initialize the ImageSet by creating the master list of images, starting its background image loading thread, and then creating the master index that maps the organization of the dataset. More...
 
bool WaitForLoadingToComplete (int nWait=int.MaxValue)
 Wait for the image set to complete loading. More...
 
bool StartRefresh (double dfReplacementPct=0.25)
 Start the refresh process which only valid when initialized with LoadLimit > 0. More...
 
bool WaitForRefreshToComplete (int nWait=int.MaxValue)
 Wait for the image refresh to complete loading. More...
 
void StopRefresh ()
 Abort any refresh currently running. More...
 
bool Load ()
 Starts loading the image set on the background thread if it is not already loading. More...
 
void Unload (bool bReload)
 Unload all images from the master list (freeing memory) and optionally reload the dataset. More...
 
QueryState CreateQueryState (bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, IMGDB_SORT sort=IMGDB_SORT.NONE)
 Create a new QueryState and optionally sort the results. More...
 
int GetTotalCount ()
 Get the total number of images in the image set whether loaded or not. More...
 
int GetLoadedCount ()
 Get the total number of images already loaded in the image set. More...
 
SimpleDatum GetImageMean (Log log, WaitHandle[] rgAbort, bool bQueryOnly)
 Get the image mean for the iamge set, or create one if it does not exist. More...
 
List< DbItemReloadIndexing ()
 Reload the indexing for the image set. More...
 
List< DbItemResetLabels ()
 Reset all labels of the image set to the original labels. More...
 
List< DbItemRelabel (LabelMappingCollection col)
 Reset the image set based on the LabelMappingCollection. More...
 
List< DbItemResetAllBoosts ()
 Reset all boosts to their original settings. More...
 
List< LabelDescriptorGetLabels ()
 Returns a list of all labels used by the data source. More...
 
string GetLabelName (int nLabel)
 Return the label name of a given label. More...
 
void SetImageMean (SimpleDatum sd, bool bSave=false)
 Sets the data source image mean. More...
 
int FindImageIndex (DateTime dt, string strDesc)
 Find the index of an image with the tiven date and (optionally) description. More...
 
SimpleDatum GetImage (int nImageId)
 Get the image at a given image ID. More...
 
SimpleDatum GetImage (QueryState state, DB_LABEL_SELECTION_METHOD labelSelectionMethod, DB_ITEM_SELECTION_METHOD imageSelectionMethod, Log log, int? nLabel=null, int nDirectIdx=-1, bool bLoadDataCriteria=false, bool bLoadDebugData=false)
 Returns the image based on its label and image selection method. More...
 
int GetCount (QueryState state, string strFilterVal=null, int? nBoostVal=null, bool bBoostValIsExact=false)
 Returns the number of images in the image set, optionally with super-boost only. More...
 
List< SimpleDatumGetImages (QueryState state, int nStartIdx, int nQueryCount=int.MaxValue, string strFilterVal=null, int? nBoostVal=null, bool bBoostValIsExact=false, bool bAttemptDirectLoad=false)
 Returns the array of images in the image set, possibly filtered with the filtering parameters. More...
 
List< SimpleDatumGetImages (QueryState state, DateTime dtStart, int nQueryCount=int.MaxValue, string strFilterVal=null, int? nBoostVal=null, bool bBoostValIsExact=false)
 Returns the array of images in the image set, possibly filtered with the filtering parameters. More...
 
List< SimpleDatumGetImages (bool bSuperboostOnly, string strFilterVal, int? nBoostVal, int[] rgIdx)
 Returns the array of images in the image set, possibly filtered with the filtering parameters. More...
 
List< SimpleResultGetAllResults (bool bRequireExtraData, int nMax)
 Returns all results from the RawImageResults table. More...
 
- Public Member Functions inherited from MyCaffe.db.image.ImageSetBase
 ImageSetBase (DatasetFactory factory, SourceDescriptor src)
 The ImageSet constructor. More...
 
void Dispose ()
 Releases the resouces used. More...
 
void SetLabelMapping (LabelMapping map)
 Set the label mapping of the ImageSet. More...
 
void UpdateLabelMapping (int nNewLabel, List< int > rgOriginalLabels)
 Update the label mapping on the ImageSet. More...
 
void ResetLabels (int nProjectId)
 Resets the labels for a project. More...
 
void DeleteLabelBoosts (int nProjectId)
 Deletes the label boosts for a project. More...
 
void AddLabelBoost (int nProjectId, int nLabel, double dfBoost)
 Adds a label boost for a project. More...
 
string GetLabelBoostsAsText (int nProjectId)
 Returns the label boosts as text. More...
 
Dictionary< int, int > LoadLabelCounts ()
 Returns the label counts as a dictionary of item pairs (int nLabel, int nCount). More...
 
void UpdateLabelCounts (int nProjectId)
 Updates the label counts for a project. More...
 
string GetLabelCountsAsText ()
 Returns the label counts for the ImageList as text. More...
 

Protected Member Functions

override void Dispose (bool bDisposing)
 Releases the resouces used. More...
 

Properties

DB_LOAD_METHOD LoadMethod [get]
 Get the image load method used on initialization. More...
 
bool IsRefreshRunning [get]
 Returns whether or not the refresh is running. More...
 
TYPE ImageSetType [get]
 Returns the type of use for the ImageSet. More...
 
- Properties inherited from MyCaffe.db.image.ImageSetBase
SourceDescriptor Source [get]
 Returns the data source of the image set. More...
 

Events

EventHandler< CalculateImageMeanArgsOnCalculateImageMean
 The OnCalculateImageMean event fires when the ImageSet needs to calculate the image mean for the image set. More...
 

Additional Inherited Members

- Protected Attributes inherited from MyCaffe.db.image.ImageSetBase
DatasetFactory m_factory
 Specifies the DatasetFactory used to work with the underlying database. More...
 
SourceDescriptor m_src
 Specifies the data source used with this Image Set. More...
 

Detailed Description

[V2 Image Database] The ImageSet2 manages the data source data including the master list of images, and the master indexes that describe the data source layout (e.g. labels, boosts, etc).

Definition at line 16 of file ImageSet2.cs.

Member Enumeration Documentation

◆ TYPE

Defines the type of image set.

Enumerator
TRAIN 

Specifies an image set containing the trianing data source.

TEST 

Specifies an image set containing the testing data source.

Definition at line 35 of file ImageSet2.cs.

Constructor & Destructor Documentation

◆ ImageSet2()

MyCaffe.db.image.ImageSet2.ImageSet2 ( TYPE  type,
Log  log,
DatasetFactory  factory,
SourceDescriptor  src,
DB_LOAD_METHOD  loadMethod,
CryptoRandom  random,
WaitHandle[]  rgAbort 
)

The ImageSet2 constructor.

Parameters
typeSpecifies the type of data source managed.
logSpecifies the output log.
factorySpecifies the data factory used to access the database data.
srcSpecifies the data source descriptor.
loadMethodSpecifies the load method used to load the data.
randomSpecifies the random number generator.
rgAbortSpecifies the cancellation handles.

Definition at line 57 of file ImageSet2.cs.

Member Function Documentation

◆ CreateQueryState()

QueryState MyCaffe.db.image.ImageSet2.CreateQueryState ( bool  bUseUniqueLabelIndexes = true,
bool  bUseUniqueImageIndexes = true,
IMGDB_SORT  sort = IMGDB_SORT.NONE 
)

Create a new QueryState and optionally sort the results.

Parameters
bUseUniqueLabelIndexesOptionally, specifies to use unique label indexes which is slightly slower, but ensures each label is hit per epoch equally (default = true).
bUseUniqueImageIndexesOptionally, specifies to use unique image indexes which is slightly slower, but ensures each image is hit per epoch (default = true).
sortOptionally, specifies a sorting method for the query set.
Returns
The new QueryState is returned.

Definition at line 218 of file ImageSet2.cs.

◆ Dispose()

override void MyCaffe.db.image.ImageSet2.Dispose ( bool  bDisposing)
protectedvirtual

Releases the resouces used.

Parameters
bDisposingSet to true when called by Dispose()

Reimplemented from MyCaffe.db.image.ImageSetBase.

Definition at line 74 of file ImageSet2.cs.

◆ FindImageIndex()

int MyCaffe.db.image.ImageSet2.FindImageIndex ( DateTime  dt,
string  strDesc 
)

Find the index of an image with the tiven date and (optionally) description.

Parameters
dtSpecifies the date to look for.
strDescSpecifies the description to look for.
Returns
If found, the image index is returned, otherwise -1 is returned.

Definition at line 339 of file ImageSet2.cs.

◆ GetAllResults()

List< SimpleResult > MyCaffe.db.image.ImageSet2.GetAllResults ( bool  bRequireExtraData,
int  nMax 
)

Returns all results from the RawImageResults table.

Parameters
bRequireExtraDataSpecifies whether or not the Extra 'target' data is required or not.
nMaxOptionally, specifies the maximum number of items to load.
Returns
The results are returned as a list of SimpleResult objects.

Definition at line 469 of file ImageSet2.cs.

◆ GetCount()

int MyCaffe.db.image.ImageSet2.GetCount ( QueryState  state,
string  strFilterVal = null,
int?  nBoostVal = null,
bool  bBoostValIsExact = false 
)

Returns the number of images in the image set, optionally with super-boost only.

Parameters
stateSpecifies the query state to use.
strFilterValOptionally, specifies the filter value that the description must match (default = null, which ignores this parameter).
nBoostValOptionally, specifies the boost value that the boost must match (default = null, which ignores this parameter).
bBoostValIsExactOptionally, specifies whether or the boost value (if specified) is to be used literally (exact = true), or as a minimum boost value.
Returns
The number of images is returned.

When using the 'nBoostValue' negative values are used to test the exact match of the boost value with the absolute value of the 'nBoostValue', ande positive values are used to test for boost values that are greater than or equal to the 'nBoostValue'.

Definition at line 408 of file ImageSet2.cs.

◆ GetImage() [1/2]

SimpleDatum MyCaffe.db.image.ImageSet2.GetImage ( int  nImageId)

Get the image at a given image ID.

Parameters
nImageIdSpecifies the image ID (within the database) of the image to retrieve.
Returns
The image is returned.

Definition at line 353 of file ImageSet2.cs.

◆ GetImage() [2/2]

SimpleDatum MyCaffe.db.image.ImageSet2.GetImage ( QueryState  state,
DB_LABEL_SELECTION_METHOD  labelSelectionMethod,
DB_ITEM_SELECTION_METHOD  imageSelectionMethod,
Log  log,
int?  nLabel = null,
int  nDirectIdx = -1,
bool  bLoadDataCriteria = false,
bool  bLoadDebugData = false 
)

Returns the image based on its label and image selection method.

Parameters
stateSpecifies the query state.
labelSelectionMethodSpecifies the label selection method.
imageSelectionMethodSpecifies the image selection method.
logSpecifies the Log for status output.
nLabelOptionally, specifies the label (default = null).
nDirectIdxOptionally, specifies the image index to use when loading a specific index (default = -1).
bLoadDataCriteriaOptionally, specifies to load the data criteria data (default = false).
bLoadDebugDataOptionally, specifies to load the debug data (default = false).
Returns
The SimpleDatum containing the image is returned.

Definition at line 370 of file ImageSet2.cs.

◆ GetImageMean()

SimpleDatum MyCaffe.db.image.ImageSet2.GetImageMean ( Log  log,
WaitHandle[]  rgAbort,
bool  bQueryOnly 
)

Get the image mean for the iamge set, or create one if it does not exist.

Parameters
logSpecifies the output log used when creating the image mean.
rgAbortSpecifies the cancellation handles used to cancel the creation of the image mean.
bQueryOnlySpecifies whether or not to only query for the mean and not calculate if missing.
Returns
The image mean is returned.

Definition at line 248 of file ImageSet2.cs.

◆ GetImages() [1/3]

List< SimpleDatum > MyCaffe.db.image.ImageSet2.GetImages ( bool  bSuperboostOnly,
string  strFilterVal,
int?  nBoostVal,
int[]  rgIdx 
)

Returns the array of images in the image set, possibly filtered with the filtering parameters.

Parameters
bSuperboostOnlySpecifies whether or not to return images with super-boost.
strFilterValspecifies the filter value that the description must match (default = null, which ignores this parameter).
nBoostValspecifies the boost value that the boost must match (default = null, which ignores this parameter).
rgIdxSpecifies a set of indexes to search for where the images returned must have an index greater than or equal to the individual index.
Returns
The list of images is returned.

When using the 'nBoostValue' negative values are used to test the exact match of the boost value with the absolute value of the 'nBoostValue', ande positive values are used to test for boost values that are greater than or equal to the 'nBoostValue'.

Definition at line 458 of file ImageSet2.cs.

◆ GetImages() [2/3]

List< SimpleDatum > MyCaffe.db.image.ImageSet2.GetImages ( QueryState  state,
DateTime  dtStart,
int  nQueryCount = int.MaxValue,
string  strFilterVal = null,
int?  nBoostVal = null,
bool  bBoostValIsExact = false 
)

Returns the array of images in the image set, possibly filtered with the filtering parameters.

Parameters
stateSpecifies the query state to use.
dtStartSpecifies a starting time from which the query is to start within the set of images.
nQueryCountOptionally, specifies a number of images to retrieve within the set (default = int.MaxValue).
strFilterValOptionally, specifies the filter value that the description must match (default = null, which ignores this parameter).
nBoostValOptionally, specifies the boost value that the boost must match (default = null, which ignores this parameter).
bBoostValIsExactOptionally, specifies whether or the boost value (if specified) is to be used literally (exact = true), or as a minimum boost value.
Returns
The list of images is returned.

When using the 'nBoostValue' negative values are used to test the exact match of the boost value with the absolute value of the 'nBoostValue', ande positive values are used to test for boost values that are greater than or equal to the 'nBoostValue'.

Definition at line 443 of file ImageSet2.cs.

◆ GetImages() [3/3]

List< SimpleDatum > MyCaffe.db.image.ImageSet2.GetImages ( QueryState  state,
int  nStartIdx,
int  nQueryCount = int.MaxValue,
string  strFilterVal = null,
int?  nBoostVal = null,
bool  bBoostValIsExact = false,
bool  bAttemptDirectLoad = false 
)

Returns the array of images in the image set, possibly filtered with the filtering parameters.

Parameters
stateSpecifies the query state to use.
nStartIdxSpecifies a starting index from which the query is to start within the set of images.
nQueryCountOptionally, specifies a number of images to retrieve within the set (default = int.MaxValue).
strFilterValOptionally, specifies the filter value that the description must match (default = null, which ignores this parameter).
nBoostValOptionally, specifies the boost value that the boost must match (default = null, which ignores this parameter).
bBoostValIsExactOptionally, specifies whether or the boost value (if specified) is to be used literally (exact = true), or as a minimum boost value.
bAttemptDirectLoadOptionaly, specifies to directly load all images not already loaded.
Returns
The list of images is returned.

When using the 'nBoostValue' negative values are used to test the exact match of the boost value with the absolute value of the 'nBoostValue', ande positive values are used to test for boost values that are greater than or equal to the 'nBoostValue'.

Definition at line 426 of file ImageSet2.cs.

◆ GetLabelName()

string MyCaffe.db.image.ImageSet2.GetLabelName ( int  nLabel)

Return the label name of a given label.

Parameters
nLabelSpecifies the label.
Returns
The name of the label is returned.

Definition at line 312 of file ImageSet2.cs.

◆ GetLabels()

List< LabelDescriptor > MyCaffe.db.image.ImageSet2.GetLabels ( )

Returns a list of all labels used by the data source.

Returns
A list of LabelDescriptors is returned.

Definition at line 302 of file ImageSet2.cs.

◆ GetLoadedCount()

int MyCaffe.db.image.ImageSet2.GetLoadedCount ( )

Get the total number of images already loaded in the image set.

Returns
The total number of images loaded is returned.

Definition at line 236 of file ImageSet2.cs.

◆ GetTotalCount()

int MyCaffe.db.image.ImageSet2.GetTotalCount ( )

Get the total number of images in the image set whether loaded or not.

Returns
The total number of images is returned.

Definition at line 227 of file ImageSet2.cs.

◆ Initialize()

QueryState MyCaffe.db.image.ImageSet2.Initialize ( bool  bSilentLoad,
bool  bUseUniqueLabelIndexes = true,
bool  bUseUniqueImageIndexes = true,
int  nMaxLoadCount = 0,
bool  bVerify = false 
)

Initialize the ImageSet by creating the master list of images, starting its background image loading thread, and then creating the master index that maps the organization of the dataset.

Parameters
bSilentLoadSpecifies to load the data silently without status output.
bUseUniqueLabelIndexesOptionally, specifies to use unique label indexes which is slightly slower, but ensures each label is hit per epoch equally (default = true).
bUseUniqueImageIndexesOptionally, specifies to use unique image indexes which is slightly slower, but ensures each image is hit per epoch (default = true).
nMaxLoadCountOptionally, specifies to automaticall start the image refresh which only applies when the number of images loaded into memory is less than the actual number of images (default = false).
bVerifyOptionally, verify the dataset indexes (only applies when using LOAD_ALL loading method (default = false).
Returns
Once initialized, the default query state for the image set is returned. This method may be called multiple times and each time returns a new QueryState.

Definition at line 102 of file ImageSet2.cs.

◆ Load()

bool MyCaffe.db.image.ImageSet2.Load ( )

Starts loading the image set on the background thread if it is not already loading.

Returns
If the load is already running false is returned, otherwise true is returned.

Definition at line 197 of file ImageSet2.cs.

◆ Relabel()

List< DbItem > MyCaffe.db.image.ImageSet2.Relabel ( LabelMappingCollection  col)

Reset the image set based on the LabelMappingCollection.

Parameters
colSpecifies the label mapping that defines how to relabel the image set.
Returns
The new list of DbItem's is returned based on the newly updated labels.

Definition at line 280 of file ImageSet2.cs.

◆ ReloadIndexing()

List< DbItem > MyCaffe.db.image.ImageSet2.ReloadIndexing ( )

Reload the indexing for the image set.

Returns
The new indexes are returned.

Definition at line 257 of file ImageSet2.cs.

◆ ResetAllBoosts()

List< DbItem > MyCaffe.db.image.ImageSet2.ResetAllBoosts ( )

Reset all boosts to their original settings.

Returns
The new list of DbItem's is returned based on the newly reset boosts.

Definition at line 291 of file ImageSet2.cs.

◆ ResetLabels()

List< DbItem > MyCaffe.db.image.ImageSet2.ResetLabels ( )

Reset all labels of the image set to the original labels.

Returns
The new list of DbItem's is returned based on the newly reset labels.

Definition at line 268 of file ImageSet2.cs.

◆ SetImageMean()

void MyCaffe.db.image.ImageSet2.SetImageMean ( SimpleDatum  sd,
bool  bSave = false 
)

Sets the data source image mean.

Parameters
sdSpecifies the iamge mean to set.
bSaveOptionally, specifies whether or not to save the image mean in the database (default = false).

Definition at line 328 of file ImageSet2.cs.

◆ StartRefresh()

bool MyCaffe.db.image.ImageSet2.StartRefresh ( double  dfReplacementPct = 0.25)

Start the refresh process which only valid when initialized with LoadLimit > 0.

Parameters
dfReplacementPctOptionally, specifies the replacement percentage (default = 0.25 or 25%).
Returns
false is returned if the refresh thread is already running, or if the number of images in memory equal the number of images in the data source.

Definition at line 162 of file ImageSet2.cs.

◆ StopRefresh()

void MyCaffe.db.image.ImageSet2.StopRefresh ( )

Abort any refresh currently running.

Definition at line 180 of file ImageSet2.cs.

◆ Unload()

void MyCaffe.db.image.ImageSet2.Unload ( bool  bReload)

Unload all images from the master list (freeing memory) and optionally reload the dataset.

Parameters
bReloadWhen true, the image set starts loading right after it is unloaded causing a refresh.

Definition at line 206 of file ImageSet2.cs.

◆ WaitForLoadingToComplete()

bool MyCaffe.db.image.ImageSet2.WaitForLoadingToComplete ( int  nWait = int.MaxValue)

Wait for the image set to complete loading.

Parameters
nWaitSpecifies the maximum number of ms to wait (default = int.MaxValue).
Returns
If the load has completed true is returned, otherwise false.

Definition at line 136 of file ImageSet2.cs.

◆ WaitForRefreshToComplete()

bool MyCaffe.db.image.ImageSet2.WaitForRefreshToComplete ( int  nWait = int.MaxValue)

Wait for the image refresh to complete loading.

Parameters
nWaitSpecifies the maximum number of ms to wait (default = int.MaxValue).
Returns
If the refresh has completed true is returned, otherwise false.

Definition at line 172 of file ImageSet2.cs.

Property Documentation

◆ ImageSetType

TYPE MyCaffe.db.image.ImageSet2.ImageSetType
get

Returns the type of use for the ImageSet.

Definition at line 188 of file ImageSet2.cs.

◆ IsRefreshRunning

bool MyCaffe.db.image.ImageSet2.IsRefreshRunning
get

Returns whether or not the refresh is running.

Definition at line 152 of file ImageSet2.cs.

◆ LoadMethod

DB_LOAD_METHOD MyCaffe.db.image.ImageSet2.LoadMethod
get

Get the image load method used on initialization.

Definition at line 144 of file ImageSet2.cs.

Event Documentation

◆ OnCalculateImageMean

EventHandler<CalculateImageMeanArgs> MyCaffe.db.image.ImageSet2.OnCalculateImageMean

The OnCalculateImageMean event fires when the ImageSet needs to calculate the image mean for the image set.

Definition at line 30 of file ImageSet2.cs.


The documentation for this class was generated from the following file: