コード例 #1
0
 /// <summary>
 /// Release all resources used.
 /// </summary>
 public void Dispose()
 {
     if (m_factory != null)
     {
         m_factory.Close();
         m_factory.Dispose();
         m_factory = null;
     }
 }
コード例 #2
0
 /// <summary>
 /// Releases the resouces used.
 /// </summary>
 /// <param name="bDisposing">Set to <i>true</i> when called by Dispose()</param>
 protected virtual void Dispose(bool bDisposing)
 {
     if (m_factory != null)
     {
         m_factory.Close();
         m_factory.Dispose();
         m_factory = null;
     }
 }
コード例 #3
0
        public void TestIndexQuery()
        {
            PreTest.Init();
            Log log = new Log("Test Dataset Factory");

            log.EnableTrace = true;

            string         strDs   = "MNIST";
            DatasetFactory factory = new DatasetFactory();
            Stopwatch      sw      = new Stopwatch();

            try
            {
                DatasetDescriptor ds = factory.LoadDataset(strDs);
                factory.Open(ds.TrainingSource.ID);

                sw.Start();
                List <DbItem> rgItems = factory.LoadImageIndexes(false);
                sw.Stop();

                log.CHECK_EQ(rgItems.Count, ds.TrainingSource.ImageCount, "The query count should match the image count!");
                factory.Close();

                log.WriteLine("Query time = " + sw.Elapsed.TotalMilliseconds.ToString("N5") + " ms.");

                sw.Restart();

                int nMin = int.MaxValue;
                int nMax = -int.MaxValue;
                for (int i = 0; i < rgItems.Count; i++)
                {
                    nMin = Math.Min(rgItems[i].Label, nMin);
                    nMax = Math.Max(rgItems[i].Label, nMax);
                }

                List <DbItem> rgBoosted = rgItems.Where(p => p.Boost > 0).ToList();

                for (int nLabel = nMin; nLabel <= nMax; nLabel++)
                {
                    List <DbItem> rgLabel = rgItems.Where(p => p.Label == nLabel).ToList();
                }

                sw.Stop();

                log.WriteLine("Query time (profile) = " + sw.Elapsed.TotalMilliseconds.ToString("N5") + " ms.");
            }
            finally
            {
                factory.Dispose();
            }
        }
コード例 #4
0
        /// <summary>
        /// Releases all resources used.
        /// </summary>
        /// <param name="bDisposing">Set to <i>true</i> when called by Dispose().</param>
        protected virtual void Dispose(bool bDisposing)
        {
            m_ds = null;

            if (m_TestingImages != null)
            {
                m_TestingImages.Dispose();
                m_TestingImages = null;
            }

            if (m_TrainingImages != null)
            {
                m_TrainingImages.Dispose();
                m_TrainingImages = null;
            }

            if (m_factory != null)
            {
                m_factory.Dispose();
                m_factory = null;
            }
        }
コード例 #5
0
ファイル: DatasetEx2.cs プロジェクト: alllucky1996/MyCaffe
        /// <summary>
        /// Releases all resources used.
        /// </summary>
        /// <param name="bDisposing">Set to <i>true</i> when called by Dispose().</param>
        protected virtual void Dispose(bool bDisposing)
        {
            m_ds = null;

            StopAutomaticRefreshSchedule(true, true);

            if (m_TestingImages != null)
            {
                m_TestingImages.Dispose();
                m_TestingImages = null;
            }

            if (m_TrainingImages != null)
            {
                m_TrainingImages.Dispose();
                m_TrainingImages = null;
            }

            if (m_factory != null)
            {
                m_factory.Dispose();
                m_factory = null;
            }
        }
コード例 #6
0
ファイル: MasterList.cs プロジェクト: Flavio58it/MyCaffe
        /// <summary>
        /// The dataLoadThread is responsible for loading the data source images in the background.
        /// </summary>
        private void dataLoadThread()
        {
            m_evtRunning.Set();
            DatasetFactory factory  = new DatasetFactory(m_factory);
            int?           nNextIdx = m_loadSequence.GetNext();
            Stopwatch      sw       = new Stopwatch();

            if (m_refreshManager != null)
            {
                m_refreshManager.Reset();
            }

            try
            {
                sw.Start();

                List <int> rgIdxBatch = new List <int>();
                int        nBatchSize = getBatchSize(m_src);

                if (m_nLoadedCount > 0)
                {
                    throw new Exception("The loaded count is > 0!");
                }

                factory.Open(m_src);

                m_log.WriteLine(m_src.Name + " loading " + m_loadSequence.Count.ToString("N0") + " items...");

                while (nNextIdx.HasValue || rgIdxBatch.Count > 0)
                {
                    if (nNextIdx.HasValue)
                    {
                        rgIdxBatch.Add(nNextIdx.Value);
                    }

                    if (rgIdxBatch.Count >= nBatchSize || !nNextIdx.HasValue)
                    {
                        List <RawImage> rgImg;

                        if (m_refreshManager == null)
                        {
                            rgImg = factory.GetRawImagesAt(rgIdxBatch[0], rgIdxBatch.Count);
                        }
                        else
                        {
                            rgImg = factory.GetRawImagesAt(rgIdxBatch, m_evtCancel);
                        }

                        if (rgImg == null)
                        {
                            break;
                        }

                        for (int j = 0; j < rgImg.Count; j++)
                        {
                            SimpleDatum sd = factory.LoadDatum(rgImg[j]);

                            if (m_refreshManager != null)
                            {
                                m_refreshManager.AddLoaded(sd);
                            }

                            m_rgImages[m_nLoadedCount] = sd;
                            m_nLoadedCount++;

                            if (sw.Elapsed.TotalMilliseconds > 1000)
                            {
                                if (m_log != null && !m_bSilent)
                                {
                                    double dfPct = m_nLoadedCount / (double)m_rgImages.Length;
                                    m_log.Progress = dfPct;
                                    m_log.WriteLine("Loading '" + m_src.Name + "' at " + dfPct.ToString("P") + " (" + m_nLoadedCount.ToString("N0") + " of " + m_rgImages.Length.ToString("N0") + ")...");
                                }

                                int nWait = WaitHandle.WaitAny(m_rgAbort.ToArray(), 0);
                                if (nWait != WaitHandle.WaitTimeout)
                                {
                                    return;
                                }

                                sw.Restart();
                            }
                        }

                        rgIdxBatch = new List <int>();
                    }

                    nNextIdx = m_loadSequence.GetNext();
                }

                if (rgIdxBatch.Count > 0)
                {
                    m_log.FAIL("Not all images were loaded!");
                }
            }
            finally
            {
                factory.Close();
                factory.Dispose();
                m_evtRunning.Reset();
                m_evtDone.Set();
            }
        }