MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DetectionEvaluateParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.ssd
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 uint m_nNumClasses;
22 uint m_nBackgroundLabelId = 0;
23 float m_fOverlapThreshold = 0.5f;
24 bool m_bEvaluateDifficultGt = true;
25 string m_strNameSizeFile;
26 ResizeParameter m_resizeParam = new ResizeParameter(false);
27
32 {
33 }
34
38 [Description("Specifies the number of classes that are actually predicted - required!")]
39 public uint num_classes
40 {
41 get { return m_nNumClasses; }
42 set { m_nNumClasses = value; }
43 }
44
51 [Description("Specifies the background class, needed for sanity check so that the background class is neither in the ground truth nor the detections.")]
53 {
54 get { return m_nBackgroundLabelId; }
55 set { m_nBackgroundLabelId = value; }
56 }
57
61 [Description("Specifies the threshold for deciding true/false positive.")]
62 public float overlap_threshold
63 {
64 get { return m_fOverlapThreshold; }
65 set { m_fOverlapThreshold = value; }
66 }
67
71 [Description("If true, also consider the difficult ground truth for evaluation.")]
73 {
74 get { return m_bEvaluateDifficultGt; }
75 set { m_bEvaluateDifficultGt = value; }
76 }
77
86 [Description("Specifies the file which contains a list of names and sizes in the same order of the input database. If provided, we scale the prediction and ground truth NormalizedBBox for evaluation.")]
87 public string name_size_file
88 {
89 get { return m_strNameSizeFile; }
90 set { m_strNameSizeFile = value; }
91 }
92
96 [Description("Specifies the resize parameter used in converting the NormalizedBBox to the original size.")]
98 {
99 get { return m_resizeParam; }
100 set { m_resizeParam = value; }
101 }
102
109 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
110 {
111 RawProto proto = RawProto.Parse(br.ReadString());
113
114 if (!bNewInstance)
115 Copy(p);
116
117 return p;
118 }
119
124 public override void Copy(LayerParameterBase src)
125 {
127
128 m_nNumClasses = p.m_nNumClasses;
129 m_nBackgroundLabelId = p.m_nBackgroundLabelId;
130 m_fOverlapThreshold = p.m_fOverlapThreshold;
131 m_bEvaluateDifficultGt = p.m_bEvaluateDifficultGt;
132 m_strNameSizeFile = p.m_strNameSizeFile;
133
134 if (p.m_resizeParam == null)
135 m_resizeParam = null;
136 else
137 m_resizeParam = p.resize_param.Clone();
138 }
139
144 public override LayerParameterBase Clone()
145 {
147 p.Copy(this);
148 return p;
149 }
150
156 public override RawProto ToProto(string strName)
157 {
158 RawProtoCollection rgChildren = new RawProtoCollection();
159
160 rgChildren.Add(new RawProto("num_classes", m_nNumClasses.ToString()));
161 rgChildren.Add(new RawProto("background_label_id", m_nBackgroundLabelId.ToString()));
162 rgChildren.Add(new RawProto("overlap_threshold", m_fOverlapThreshold.ToString()));
163 rgChildren.Add(new RawProto("evaluate_difficult_gt", m_bEvaluateDifficultGt.ToString()));
164 rgChildren.Add(new RawProto("name_size_file", m_strNameSizeFile));
165
166 if (m_resizeParam != null)
167 rgChildren.Add(m_resizeParam.ToProto("resize_param"));
168
169 return new RawProto(strName, "", rgChildren);
170 }
171
178 {
180 string strVal;
181
182 if ((strVal = rp.FindValue("num_classes")) != null)
183 p.num_classes = uint.Parse(strVal);
184
185 if ((strVal = rp.FindValue("background_label_id")) != null)
186 p.background_label_id = uint.Parse(strVal);
187
188 if ((strVal = rp.FindValue("overlap_threshold")) != null)
190
191 if ((strVal = rp.FindValue("evaluate_difficult_gt")) != null)
192 p.evaulte_difficult_gt = bool.Parse(strVal);
193
194 p.name_size_file = rp.FindValue("name_size_file");
195
196 RawProto rpResize = rp.FindChild("resize_param");
197 if (rpResize != null)
199
200 return p;
201 }
202 }
203}
The BaseParameter class is the base class for all other parameter classes.
static float ParseFloat(string strVal)
Parse float values using the US culture if the decimal separator = '.', then using the native culture...
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
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
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
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the DetectionEvaluateLayer.
uint background_label_id
Specifies the background class.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
bool evaulte_difficult_gt
Specifies whether or not to consider the ground truth for evaluation.
static DetectionEvaluateParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
string name_size_file
Specifies the file which contains a list of names and sizes in the same order of the input database....
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
uint num_classes
Specifies the number of classes that are actually predicted - required!
float overlap_threshold
Specifies the threshold for deciding true/false positive.
ResizeParameter resize_param
Specifies the resize parameter used in converting the NormalizedBBox to the original size.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Specifies the parameters for the ResizeParameter for use with SSD.
ResizeParameter Clone()
Return a copy of this object.
static new ResizeParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
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