MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DatabaseLoader.cs
2using MyCaffe.db.image;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
9
11{
15 public class DatabaseLoader
16 {
18
23 {
24 }
25
32 {
33 int nDsID = m_db.GetDatasetID(strDs);
34 return LoadDatasetFromDb(nDsID);
35 }
36
43 {
44 Dataset ds = m_db.GetDataset(nDsID);
45 if (ds == null)
46 return null;
47
48 GroupDescriptor grpd = LoadGroupFromDb(ds.DatasetGroupID);
49 SourceDescriptor srcTrain = LoadSourceFromDb(ds.TrainingSourceID);
50 SourceDescriptor srcTest = LoadSourceFromDb(ds.TestingSourceID);
51
52 string strCreatorName = m_db.GetDatasetCreatorName(ds.DatasetCreatorID.GetValueOrDefault(0));
53
54 return new DatasetDescriptor(ds.ID, ds.Name, grpd, null, srcTrain, srcTest, strCreatorName, ds.Description);
55 }
56
63 {
64 Source src = m_db.GetSource(nSrcId.GetValueOrDefault(0));
65 if (src == null)
66 return null;
67
68 int nW = src.ImageWidth.GetValueOrDefault(0);
69 int nH = src.ImageHeight.GetValueOrDefault(0);
70 int nC = src.ImageChannels.GetValueOrDefault(0);
71 bool bIsReal = src.ImageEncoded.GetValueOrDefault(true);
72 int nCount = src.ImageCount.GetValueOrDefault(0);
73
74 SourceDescriptor srcd = new SourceDescriptor(src.ID, src.Name, nW, nH, nC, bIsReal, false, 0, null, nCount);
76
77 return srcd;
78 }
79
85 public GroupDescriptor LoadGroupFromDb(int? nGrpId)
86 {
87 DatasetGroup grp = m_db.GetDatasetGroup(nGrpId.GetValueOrDefault(0));
88 if (grp == null)
89 return null;
90
91 return new GroupDescriptor(grp.ID, grp.Name, null);
92 }
93
100 {
102 List<ValueStream> rgStrm = m_db.GetAllValueStreams(nSrcID);
103 List<ValueItem> rgItem = m_db.GetAllValueItems(nSrcID);
104
105 if (rgItem.Count == 0 || rgStrm.Count == 0)
106 return null;
107
108
109 foreach (ValueStream strm in rgStrm)
110 {
112 strm.Name,
113 strm.Ordering.GetValueOrDefault(0),
114 (STREAM_CLASS_TYPE)strm.ClassTypeID,
115 (STREAM_VALUE_TYPE)strm.ValueTypeID,
116 strm.StartTime,
117 strm.EndTime,
118 strm.SecondsPerStep,
119 strm.TotalSteps.GetValueOrDefault(0));
120
121 td.ValueStreamDescriptors.Add(vsd);
122 }
123
124 foreach (ValueItem vi in rgItem)
125 {
126 td.ValueItemDescriptors.Add(new ValueItemDescriptor(vi.ID, vi.Name, vi.StartTime, vi.EndTime, vi.Steps));
127 }
128
129 return td;
130 }
131
137 {
138 if (ds == null)
139 return;
140
141 if (ds.TrainingSource != null)
143
144 if (ds.TestingSource != null)
146 }
147 }
148}
int ID
Get/set the database ID of the item.
The DatasetDescriptor class describes a dataset which contains both a training data source and testin...
SourceDescriptor TrainingSource
Get/set the training data source.
SourceDescriptor TestingSource
Get/set the testing data source.
The GroupDescriptor class defines a group.
The SourceDescriptor class contains all information describing a data source.
TemporalDescriptor TemporalDescriptor
Get/set the temporal descriptor (if any).
The TemporalDescriptor is used to describe a temporal aspects of the data source.
The ValueItemDescriptor describes each value item (e.g., customer, station or stock)
The value stream descriptor describes a single value stream within a value item.
Dataset GetDataset(int nID, ConnectInfo ci=null)
Returns the Dataset entity for a dataset ID.
Definition: Database.cs:4648
string GetDatasetCreatorName(int nDatasetCreatorID, ConnectInfo ci=null)
Returns the name of a dataset creator given its ID.
Definition: Database.cs:5225
int GetDatasetID(string strName, ConnectInfo ci=null)
Returns a datasets ID given its name.
Definition: Database.cs:4612
Source GetSource(string strName, ConnectInfo ci=null)
Returns the Source entity given a data source name.
Definition: Database.cs:4051
DatasetGroup GetDatasetGroup(int nGroupID, ConnectInfo ci=null)
Returns the DatasetGroup entity given a group ID.
Definition: Database.cs:4897
The DatasetLoader is used to load descriptors from the database.
GroupDescriptor LoadGroupFromDb(int? nGrpId)
Load a dataset group with the specified ID from the database.
TemporalDescriptor LoadTemporalFromDb(int nSrcID)
Load the temporal descriptor for the specified source ID from the database.
void LoadTemporalFromDb(DatasetDescriptor ds)
Load the temporal descriptors for the specified source ID from the database.
DatasetDescriptor LoadDatasetFromDb(int nDsID)
Load a dataset with the specified ID from the database.
SourceDescriptor LoadSourceFromDb(int? nSrcId)
Load a data source with the specified ID from the database.
DatasetDescriptor LoadDatasetFromDb(string strDs)
Load a dataset with the specified name from the database.
The DatabaseTemporal is used to manage all temporal specific database objects.
List< ValueStream > GetAllValueStreams(int nSrcID)
Returns a list of all value streams associated with a SourceID.
List< ValueItem > GetAllValueItems(int nSrcID)
Returns a list of all value items associated with a SourceID.
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.
Definition: Annotation.cs:12
The MyCaffe.db.image namespace contains all image database related classes.
Definition: Database.cs:18
The MyCaffe.db.temporal namespace contains all classes used to create the MyCaffeTemporalDatabase in-...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12