2using System.Collections.Generic;
19 List<int> m_rgIdx =
new List<int>();
20 int m_nCurrentIdx = 0;
39 get {
return m_label; }
40 set { m_label = value; }
48 get {
return m_rgImages.Length; }
67 get {
return m_rgImages[nIdx]; }
68 set { m_rgImages[nIdx] = value; }
78 if (m_nCurrentIdx == m_rgImages.Length)
90 if (m_nCurrentIdx < m_rgImages.Length)
92 m_rgImages[m_nCurrentIdx] = s;
106 throw new ArgumentException(
"Label balancing image selection only supports the RANDOM and RANDOM+BOOST selection methods");
108 if (m_nCurrentIdx == 0)
115 return GetImage(m_rgImages, m_rgIdx, m_nCurrentIdx, nIdx, m_random, selectionMethod, ref nLastIdx, ref nFixedIdx, out nImageIdx);
135 IEnumerable<SimpleDatum> iQuery = rgImages.Where(p => p !=
null && p.Boost > 0);
136 List<SimpleDatum> rgItems =
new List<SimpleDatum>(iQuery);
138 if (rgItems.Count > 0)
140 if (rgIdx.Count > rgItems.Count)
143 if (rgIdx.Count == 0)
145 for (
int i = 0; i < rgItems.Count; i++)
153 nIdx = rgIdx[random.
Next(rgIdx.Count)];
165 if (rgIdx.Count < nMin)
169 for (
int i = 0; i < rgImages.Length; i++)
177 nIdx = nLastIndex + 1;
179 if (nIdx == rgIdx.Count)
186 nIdx = rgIdx[random.
Next(rgIdx.Count)];
198 if (nFixedIndex >= 0)
201 if (nIdx >= rgImages.Length)
202 nIdx = nIdx % rgImages.Length;
207 return rgImages[nIdx];
215 for (
int i = 0; i < m_rgImages.Length; i++)
217 m_rgImages[i] =
null;
225 protected virtual void Dispose(
bool bDisposing)
227 if (m_random !=
null)
The CryptoRandom is a random number generator that can use either the standard .Net Random objec or t...
int Next(int nMinVal, int nMaxVal, bool bMaxInclusive=true)
Returns a random int within the range
The SimpleDatum class holds a data input within host memory.
SimpleDatum Add(SimpleDatum d)
Creates a new SimpleDatum and adds another SimpleDatum to it.
The LabelDescriptor class describes a single label.
int ImageCount
Specifies the number of images under this label.
The LabelSet 'points' into the main image list via references objects that are already created in the...
static SimpleDatum GetImage(SimpleDatum[] rgImages, List< int > rgIdx, int nCount, int nIdx, CryptoRandom random, DB_ITEM_SELECTION_METHOD selectionMethod, ref int nLastIndex, ref int nFixedIndex, out int nImageIdx)
Returns an image from a list of images.
void Dispose()
Releases all resources used.
void Add(SimpleDatum s)
Adds an image to the current index and then advances the internal index.
SimpleDatum GetImage(int nIdx, DB_ITEM_SELECTION_METHOD selectionMethod)
Returns an image from the LabelSet using the image selection method.
LabelSet(LabelDescriptor lbl, CryptoRandom random)
The LabelSet constructor.
int Count
Returns the number of images in the label set.
virtual void Dispose(bool bDisposing)
Releases all resources used.
bool IsLoaded
Returns whether or not the label set is fully loaded or not (which is the case when first using LOAD_...
void Unload()
Unload all images from the label set.
LabelDescriptor Label
Get/set the label of the LabelSet.
void Clear()
Clears the list of images.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
DB_ITEM_SELECTION_METHOD
Defines the item (e.g., image or temporal item) selection 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-...