2using System.Collections.Generic;
15 List<DatasetEx2> m_rgDatasets =
new List<DatasetEx2>();
16 bool m_bUseTrainingSourcesForTesting =
false;
18 object m_syncObj =
new object();
34 return m_rgDatasets.Remove(ds);
44 bool bReleased =
true;
115 throw new Exception(
"Failed to create a new query state for dataset ID = " + nDsId.ToString() +
".");
136 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs.ToString() +
"'.");
157 get {
return m_rgDatasets.Count; }
166 m_bUseTrainingSourcesForTesting = bEnable;
179 get {
return m_bUseTrainingSourcesForTesting; }
189 get {
return m_rgDatasets[nIdx]; }
233 if (ds.
Find(nSrcId) !=
null)
249 if (m_lastImgSet !=
null && m_lastImgSet.
Source.ID == nSourceID)
258 m_lastImgSet = imgSet;
263 throw new Exception(
"Could not find source with ID = " + nSourceID.ToString() +
"!");
276 if (m_lastImgSet !=
null && m_lastImgSet.
Source.Name == strSource)
285 m_lastImgSet = imgSet;
290 throw new Exception(
"Could not find source with Name = " + strSource +
"!");
312 throw new Exception(
"Failed to create a new query state for dataset ID = " + nDsId.ToString() +
".");
334 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
356 throw new Exception(
"Failed to create a new query state for dataset ID = " + nDsId.ToString() +
".");
378 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
399 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsId.ToString() +
"'.");
420 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
436 public bool StartRefresh(
string strDs,
bool bTraining,
bool bTesting,
double dfReplacementPct)
449 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
463 public bool StopRefresh(
string strDs,
bool bTraining,
bool bTesting)
476 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
491 public bool StartRefresh(
int nDsID,
bool bTraining,
bool bTesting,
double dfReplacementPct)
504 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsID.ToString() +
"'.");
531 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsID.ToString() +
"'.");
554 throw new Exception(
"Failed to create a new query state for dataset name = '" + strDs +
"'.");
574 throw new Exception(
"Failed to create a new query state for dataset name = '" + strDs +
"'.");
589 dfReplacementPct = 0;
590 nTrainingRefreshCount = 0;
591 nTestingRefreshCount = 0;
601 throw new Exception(
"Failed to create a new query state for dataset name = '" + strDs +
"'.");
623 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsID.ToString() +
"'.");
643 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsID.ToString() +
"'.");
658 dfReplacementPct = 0;
659 nTrainingRefreshCount = 0;
660 nTestingRefreshCount = 0;
670 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsID.ToString() +
"'.");
689 return ds.
CreateQueryState(bUseUniqueLabelIndexes, bUseUniqueImageIndexes, sort);
692 throw new Exception(
"Failed to create a new query state for dataset ID = " + nDsId.ToString() +
".");
711 return ds.
CreateQueryState(bUseUniqueLabelIndexes, bUseUniqueImageIndexes, sort);
714 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
734 throw new Exception(
"Failed to create a new query state for dataset ID = '" + nDsId.ToString() +
"'.");
754 throw new Exception(
"Failed to create a new query state for dataset = '" + strDs +
"'.");
817 throw new Exception(
"Could not find query state for data source with Name = " + strSource +
"!");
840 throw new Exception(
"Could not find query state for data source with ID = " + nSrcId.ToString() +
"!");
850 m_rgDatasets.Add(ds);
857 protected virtual void Dispose(
bool bDisposing)
864 m_rgDatasets.Clear();
881 return m_rgDatasets.GetEnumerator();
888 System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
890 return m_rgDatasets.GetEnumerator();
The LabelMappingCollection manages a collection of LabelMapping's.
The SimpleDatum class holds a data input within host memory.
[V2 Image Database] The DatasetEx2 class provides the in-memory dataset functionality that is used by...
long CreateQueryState(bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, IMGDB_SORT sort=IMGDB_SORT.NONE)
Create a new QueryState on the dataset.
int? DatasetID
Returns the dataset ID of the dataset managesd by the DatasetEx object.
bool StartAutomaticRefreshSchedule(bool bTraining, bool bTesting, int nPeriodInMs, double dfReplacementPct)
Start the automatic refresh schedule on the training and/or testing data sources.
bool SetDefaultQueryState(long lQueryState)
Set the default query state to a new query state.
bool StopAutomaticRefreshSchedule(bool bTraining, bool bTesting)
Stop the automatic refresh schedule on the training and/or testing data sources.
bool UseTrainingImagesForTesting
Get/set whether or not to use the training images when testing.
QueryState FindQueryState(long lQueryState, ImageSet2.TYPE type)
Returns the query state for a given query state handle and type.
bool FreeQueryState(long lHandle)
Free an existing query state.
void Relabel(LabelMappingCollection col)
Relabels both the testing and training image sets using the label mapping collection.
void StopRefresh(bool bTraining=true, bool bTesting=true)
Stop any refresh operation currently running.
ImageSet2 Find(int nSourceID)
Returns the ImageSet corresponding to a data source ID.
bool SaveImageMean(int nSrcId, SimpleDatum sd, bool bUpdate)
Saves the image mean in a SimpleDatum to the database.
bool GetAutomaticRefreshSchedule(out int nPeriodInMs, out double dfReplacementPct, out int nTrainingRefreshCount, out int nTestingRefreshCount)
Get the automatic refresh schedule status and its period and replacement percentage.
virtual void Dispose(bool bDisposing)
Releases all resources used.
void ReloadIndexing()
Reload the indexing for both the training and testing data sources.
bool WaitForLoadingToComplete(bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for either the training, testing or both data sources to complete loading.
bool WaitForRefreshToComplete(bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for either the training, testing or both data sources to complete refreshing.
int RemoveUser(Guid user)
Remove a user of the dataset.
bool IsRefreshRunning(bool bTraining, bool bTesting)
Returns whether or not the refresh is running on the training and/or testing data source.
SimpleDatum QueryImageMean(int nSrcId)
Query the image mean for a data source.
void StartRefresh(bool bTraining=true, bool bTesting=true, double dfReplacementPct=0.25)
Start an image refresh on the training and/or testing data sources.
string DatasetName
Returns the dataset name of the dataset managesd by the DatasetEx object.
[V2 Image Database] The DatasetExCollection2 contains a list of DatasetEx2 objects.
bool SaveImageMean(int nSrcID, SimpleDatum sd, bool bUpdate)
Saves the image mean in a SimpleDatum to the database for a data source.
bool StartAutomaticRefreshSchedule(int nDsID, bool bTraining, bool bTesting, int nPeriodInMs, double dfReplacementPct)
Start the automatic refresh cycle to occur on specified period increments.
SimpleDatum QueryImageMean(int nSrcID)
Returns the image mean for a data source.
void Dispose()
Releases all resources used by the collection.
bool StartAutomaticRefreshSchedule(string strDs, bool bTraining, bool bTesting, int nPeriodInMs, double dfReplacementPct)
Start the automatic refresh cycle to occur on specified period increments.
ImageSet2 FindImageset(string strSource)
Searches for the ImageSet with a given data source name.
bool WaitForDatasetToLoad(string strDs, bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for the dataset loading to complete.
long CreateQueryState(int nDsId, bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, IMGDB_SORT sort=IMGDB_SORT.NONE)
Create a new query state, optionally with a certain sorting.
QueryState FindQueryState(long lQueryState, int nSrcId)
Returns the query state based on the handle and data source where the dataset that owns the data sour...
bool StopRefresh(string strDs, bool bTraining, bool bTesting)
Stop a refresh operation running on the dataset.
bool GetScheduledAutoRefreshInformation(int nDsID, out int nPeriodInMs, out double dfReplacementPct, out int nTrainingRefreshCount, out int nTestingRefreshCount)
Returns whether or not a scheduled refresh is running and if so at what period and replacement percen...
IEnumerator< DatasetEx2 > GetEnumerator()
Returns the enumerator for the collection.
bool FreeQueryState(int nDsId, long lHandle)
Frees a query state from a given dataset.
DatasetEx2 FindDataset(int nDatasetID)
Searches for the dataset with a dataset ID.
virtual void Dispose(bool bDisposing)
Releases all resources used by the collection.
void Relabel(LabelMappingCollection col)
Relabels all datasets using a label mapping collection.
void ReloadIndexing(string strDs)
Reload the dataset's indexing.
bool SetDefaultQueryState(string strDs, long lQueryState)
Set the default query state to the query state specified for the dataset specified.
DatasetEx2 FindDatasetFromSource(int nSrcId)
Searches for the dataset containing the given Source ID.
bool RemoveDataset(DatasetEx2 ds)
Remove the dataset specified.
int Count
Returns the number of datasets in the collection.
bool WaitForDatasetToRefresh(string strDs, bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for the dataset refreshing to complete.
bool StartRefresh(string strDs, bool bTraining, bool bTesting, double dfReplacementPct)
Start a refresh on the dataset by replacing a specified percentage of the images with images from the...
DatasetEx2 FindDataset(string strDs)
Searches for the dataset with the dataset name.
long CreateQueryState(string strDs, bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, IMGDB_SORT sort=IMGDB_SORT.NONE)
Create a new query state, optionally with a certain sorting.
DatasetExCollection2()
The DatasetExCollection2 constructor.
bool StartRefresh(int nDsID, bool bTraining, bool bTesting, double dfReplacementPct)
Start a refresh on the dataset by replacing a specified percentage of the images with images from the...
bool WaitForDatasetToLoad(int nDsId, bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for the dataset loading to complete.
bool SetDefaultQueryState(int nDsId, long lQueryState)
Set the default query state to the query state specified for the dataset specified.
void ReloadIndexing(int nDsId)
Reload the dataset's indexing.
bool GetScheduledAutoRefreshInformation(string strDs, out int nPeriodInMs, out double dfReplacementPct, out int nTrainingRefreshCount, out int nTestingRefreshCount)
Returns whether or not a scheduled refresh is running and if so at what period and replacement percen...
bool FreeQueryState(string strDs, long lHandle)
Frees a query state from a given dataset.
bool WaitForDatasetToRefresh(int nDsId, bool bTraining, bool bTesting, int nWait=int.MaxValue)
Wait for the dataset refreshing to complete.
bool IsRefreshRunning(string strDs, bool bTraining, bool bTesting)
Returns true if the refresh operation running.
bool StopRefresh(int nDsID, bool bTraining, bool bTesting)
Stop a refresh operation running on the dataset.
QueryState FindQueryState(long lQueryState, string strSource)
Returns the query state based on the handle and data source where the dataset that owns the data sour...
bool RemoveUser(Guid user)
Removes a user from the list of users using the DatasetExCollection.
void Add(DatasetEx2 ds)
Adds a DatasetEx to the collection.
void Reset()
Resets the last image set used to null, thus clearing it.
bool StopAutomaticRefreshSchedule(int nDsID, bool bTraining, bool bTesting)
Stop the automatic refresh schedule running on a dataset.
ImageSet2 FindImageset(int nSourceID)
Searches for the ImageSet with a given data source ID.
bool StopAutomaticRefreshSchedule(string strDs, bool bTraining, bool bTesting)
Stop the automatic refresh schedule running on a dataset.
bool UseTrainingSourcesForTesting
Returns whether or not the training sources are set to be used for testing.
void EnableUsingTrainingSourcesForTesting(bool bEnable)
Enable/disable the using of the training sources for testing on all datasets.
bool IsRefreshRunning(int nDsId, bool bTraining, bool bTesting)
Returns true if the refresh operation running.
[V2 Image Database] The ImageSet2 manages the data source data including the master list of images,...
TYPE ImageSetType
Returns the type of use for the ImageSet.
SourceDescriptor Source
Returns the data source of the image set.
Initially the QueryState is copied from the MasterIndexes and during each query is altered by removin...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
IMGDB_SORT
Defines the sorting method.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...