MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
AnnotatedDataParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
20{
28 [Serializable]
29 [TypeConverter(typeof(ExpandableObjectConverter))]
31 {
33 List<BatchSampler> m_rgBatchSampler = new List<BatchSampler>();
34 string m_strLabelFile;
35
36
41 {
42 }
43
47 [Description("Get/set the annotation type.")]
49 {
50 get { return m_type; }
51 set { m_type = value; }
52 }
53
57 [Description("Get/set the batch sampler.")]
58 public List<BatchSampler> batch_sampler
59 {
60 get { return m_rgBatchSampler; }
61 set { m_rgBatchSampler = value; }
62 }
63
67 [Description("Get/set the label map file.")]
68 public string label_map_file
69 {
70 get { return m_strLabelFile; }
71 set { m_strLabelFile = value; }
72 }
73
80 public override object Load(BinaryReader br, bool bNewInstance = true)
81 {
82 RawProto proto = RawProto.Parse(br.ReadString());
84
85 if (!bNewInstance)
86 Copy(p);
87
88 return p;
89 }
90
95 public override void Copy(LayerParameterBase src)
96 {
97 if (src is AnnotatedDataParameter)
98 {
100 m_type = p.m_type;
101 m_strLabelFile = p.m_strLabelFile;
102
103 m_rgBatchSampler = new List<BatchSampler>();
104 foreach (BatchSampler bs in p.m_rgBatchSampler)
105 {
106 m_rgBatchSampler.Add(bs.Clone());
107 }
108 }
109 }
110
115 public override LayerParameterBase Clone()
116 {
118 p.Copy(this);
119 return p;
120 }
121
127 public override RawProto ToProto(string strName)
128 {
129 RawProtoCollection rgChildren = new RawProtoCollection();
130
131 rgChildren.Add(new RawProto("anno_type", ((int)m_type).ToString()));
132 rgChildren.Add(new RawProto("label_map_file", m_strLabelFile));
133
134 foreach (BatchSampler bs in m_rgBatchSampler)
135 {
136 rgChildren.Add(bs.ToProto("batch_sampler"));
137 }
138
139 return new RawProto(strName, "", rgChildren);
140 }
141
148 {
150 string strVal;
151
152 if ((strVal = rp.FindValue("anno_type")) != null)
153 p.m_type = (SimpleDatum.ANNOTATION_TYPE)int.Parse(strVal);
154
155 if ((strVal = rp.FindValue("label_map_file")) != null)
156 p.m_strLabelFile = strVal;
157
158 RawProtoCollection col = rp.FindChildren("batch_sampler");
159 foreach (RawProto rp1 in col)
160 {
161 p.m_rgBatchSampler.Add(BatchSampler.FromProto(rp1));
162 }
163
164 return p;
165 }
166 }
167}
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
RawProtoCollection FindChildren(params string[] rgstrName)
Searches for all children with a given name in this node's children.
Definition: RawProto.cs:263
The SimpleDatum class holds a data input within host memory.
Definition: SimpleDatum.cs:161
ANNOTATION_TYPE
Specifies the annotation type when using annotations.
Definition: SimpleDatum.cs:204
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the InputLayer.
SimpleDatum.ANNOTATION_TYPE anno_type
Get/set the annotation type.
List< BatchSampler > batch_sampler
Get/set the batch sampler.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override object Load(BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
string label_map_file
Get/set the label map file.
static AnnotatedDataParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
Specifies a sample of batch of bboxes with provided constraints in SSD.
Definition: BatchSampler.cs:22
static BatchSampler FromProto(RawProto rp)
Parse a new BatchSampler from a RawProto.
override RawProto ToProto(string strName)
Converts the BatchSampler to a RawProto.
BatchSampler Clone()
Creates a copy of the BatchSampler.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.ssd namespace contains all SSD related parameter objects that correspond to the nat...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12