/// <summary> /// The AnnotatedDataLayer constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">provides LayerParameter annotated_data_param.</param> /// <param name="db">Specifies the external database to use.</param> /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param> public AnnotatedDataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabaseBase db, CancelEvent evtCancel) : base(cuda, log, p, db, evtCancel) { m_type = LayerParameter.LayerType.ANNOTATED_DATA; m_random = new CryptoRandom(CryptoRandom.METHOD.DEFAULT, p.transform_param.random_seed.GetValueOrDefault(0)); m_tMinusOne = (T)Convert.ChangeType(-1, typeof(T)); if (db == null) { m_log.FAIL("Currently, the AnnotatedDataLayer requires the MyCaffe Image Database!"); } Tuple <IMGDB_LABEL_SELECTION_METHOD, IMGDB_IMAGE_SELECTION_METHOD> kvSel = db.GetSelectionMethod(); IMGDB_IMAGE_SELECTION_METHOD imgSel = kvSel.Item2; if (m_param.data_param.enable_pair_selection.HasValue) { if (m_param.data_param.enable_pair_selection.Value) { imgSel |= IMGDB_IMAGE_SELECTION_METHOD.PAIR; } else { imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.PAIR); } } if (m_param.data_param.enable_random_selection.HasValue) { if (m_param.data_param.enable_random_selection.Value) { imgSel |= IMGDB_IMAGE_SELECTION_METHOD.RANDOM; } else { imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.RANDOM); } } if (!db.GetLoadImageDataCriteria()) { m_log.WriteError(new Exception("The 'Load Image Data Criteria' must be set to TRUE in order to load the Annotation data.")); } db.SetSelectionMethod(null, imgSel); m_db = new data.DB <T>(db); m_db.Open(p.data_param.source); if (p.data_param.display_timing) { m_swTimerBatch = new Stopwatch(); m_swTimerTransaction = new Stopwatch(); } m_sampler = new SsdSampler <T>(cuda, log); }
/// <summary> /// The DataLayer constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies the LayerParameter data_param</param> /// <param name="db">Specifies the external database to use.</param> /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param> public DataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabaseBase db, CancelEvent evtCancel) : base(cuda, log, p, db, evtCancel) { m_type = LayerParameter.LayerType.DATA; if (p.data_param.synchronize_target) { m_rgBatchLabels = new LabelCollection(); } Tuple <IMGDB_LABEL_SELECTION_METHOD, IMGDB_IMAGE_SELECTION_METHOD> kvSel = db.GetSelectionMethod(); IMGDB_IMAGE_SELECTION_METHOD imgSel = kvSel.Item2; if (m_param.data_param.enable_pair_selection.HasValue) { if (m_param.data_param.enable_pair_selection.Value) { imgSel |= IMGDB_IMAGE_SELECTION_METHOD.PAIR; } else { imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.PAIR); } } if (m_param.data_param.enable_random_selection.HasValue) { if (m_param.data_param.enable_random_selection.Value) { imgSel |= IMGDB_IMAGE_SELECTION_METHOD.RANDOM; } else { imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.RANDOM); } } db.SetSelectionMethod(null, imgSel); m_db = new data.DB <T>(db); m_db.Open(p.data_param.source); if (p.data_param.display_timing) { m_swTimerBatch = new Stopwatch(); m_swTimerTransaction = new Stopwatch(); } if (m_param.transform_param.mask_param != null && m_param.transform_param.mask_param.Active) { m_blobMask = new Blob <T>(cuda, log, false); m_blobMask1 = new Blob <T>(cuda, log, false); } if (m_param.data_param.enable_debug_output) { m_blobDebug1 = new Blob <T>(cuda, log, false); } }