MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
NonMaximumSuppressionParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
10namespace MyCaffe.param.ssd
11{
19 [Serializable]
20 [TypeConverter(typeof(ExpandableObjectConverter))]
22 {
23 float m_fNmsThreshold = 0.3f;
24 int? m_nTopK = null;
25 float m_fEta = 1.0f;
26
31 public NonMaximumSuppressionParameter(bool bActive) : base(bActive)
32 {
33 }
34
38 [Description("Get/set the threshold to be used in nms.")]
39 public float nms_threshold
40 {
41 get { return m_fNmsThreshold; }
42 set { m_fNmsThreshold = value; }
43 }
44
48 [Description("Get/set the maximum number of results kept.")]
49 public int? top_k
50 {
51 get { return m_nTopK; }
52 set { m_nTopK = value; }
53 }
54
58 [Description("Get/set the parameter for adaptive nms.")]
59 public float eta
60 {
61 get { return m_fEta; }
62 set { m_fEta = value; }
63 }
64
69 public override void Copy(OptionalParameter src)
70 {
71 base.Copy(src);
72
74 {
76 m_fNmsThreshold = p.nms_threshold;
77 m_nTopK = p.top_k;
78 m_fEta = p.eta;
79 }
80 }
81
87 {
89 p.Copy(this);
90 return p;
91 }
92
98 public override RawProto ToProto(string strName)
99 {
100 RawProto rpBase = base.ToProto("option");
101 RawProtoCollection rgChildren = new RawProtoCollection();
102
103 rgChildren.Add(rpBase);
104 rgChildren.Add(new RawProto("nms_threshold", nms_threshold.ToString()));
105
106 if (top_k.HasValue)
107 rgChildren.Add(new RawProto("top_k", top_k.Value.ToString()));
108
109 rgChildren.Add(new RawProto("eta", eta.ToString()));
110
111 return new RawProto(strName, "", rgChildren);
112 }
113
120 {
122 string strVal;
123
124 RawProto rpOption = rp.FindChild("option");
125 if (rpOption != null)
126 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
127
128 if ((strVal = rp.FindValue("nms_threshold")) != null)
130
131 if ((strVal = rp.FindValue("top_k")) != null)
132 p.top_k = int.Parse(strVal);
133
134 if ((strVal = rp.FindValue("eta")) != null)
135 p.eta = BaseParameter.ParseFloat(strVal);
136
137 return p;
138 }
139 }
140}
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
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The OptionalParameter is the base class for parameters that are optional such as the MaskParameter,...
static OptionalParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
OptionalParameter(bool bActive=false)
The constructor.
bool Active
When active, the parameter is used, otherwise it is ignored.
Specifies the parameters for the NonMaximumSuppressionParameter used with SSD.
float eta
Get/set the parameter for adaptive nms.
int? top_k
Get/set the maximum number of results kept.
float nms_threshold
Get/set the threshold to be used in nms.
override void Copy(OptionalParameter src)
Copy the object.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
NonMaximumSuppressionParameter Clone()
Return a clone of the object.
static new NonMaximumSuppressionParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
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