2using System.Collections.Generic;
7using System.Threading.Tasks;
20 [TypeConverter(typeof(ExpandableObjectConverter))]
23 List<float> m_rgMinSize =
new List<float>();
24 List<float> m_rgMaxSize =
new List<float>();
25 List<float> m_rgAspectRatio =
new List<float>();
28 List<float> m_rgVariance =
new List<float>();
29 uint? m_nImgSize =
null;
32 float? m_fStep =
null;
33 float? m_fStepH =
null;
34 float? m_fStepW =
null;
35 float m_fOffset = 0.5f;
75 throw new Exception(
"Unknown CodeType '" + str +
"'!");
89 [Description(
"Specifies the minimum box size (in pixels) and is required!")]
92 get {
return m_rgMinSize; }
93 set { m_rgMinSize = value; }
99 [Description(
"Specifies the maximum box size (in pixels) and is required!")]
102 get {
return m_rgMaxSize; }
103 set { m_rgMaxSize = value; }
110 [Description(
"Specifies various aspect ratios. Duplicate ratios are ignored. If none are provided, a default ratio of 1 is used.")]
113 get {
return m_rgAspectRatio; }
114 set { m_rgAspectRatio = value; }
122 [Description(
"Specifies whether or not to flip each aspect ratio. For example, if there is an aspect ratio 'r' we will generate aspect ratio '1.0/r' as well.")]
125 get {
return m_bFlip; }
126 set { m_bFlip = value; }
132 [Description(
"Specifies whether or not to clip the prior so that it is within [0,1].")]
135 get {
return m_bClip; }
136 set { m_bClip = value; }
142 [Description(
"Specifies the variance for adjusting the prior boxes.")]
145 get {
return m_rgVariance; }
146 set { m_rgVariance = value; }
158 [Description(
"Specifies the image size. By default we calculate the img_height, img_width, step_x and step_y based on bottom[0] (feat) and bottom[1] (img). Unless these values are explicitly provided here. Either the img_h and img_w are used or the img_size, but not both.")]
161 get {
return m_nImgSize; }
162 set { m_nImgSize = value; }
174 [Description(
"Specifies the image height. By default we calculate the img_height, img_width, step_x and step_y based on bottom[0] (feat) and bottom[1] (img). Unless these values are explicitly provided here. Either the img_h and img_w are used or the img_size, but not both.")]
177 get {
return m_nImgH; }
178 set { m_nImgH = value; }
190 [Description(
"Specifies the image width. By default we calculatethe img_height, img_width, step_x and step_y based on bottom[0] (feat) and bottom[1] (img). Unless these values are explicitly provided here. Either the img_h and img_w are used or the img_size, but not both.")]
193 get {
return m_nImgW; }
194 set { m_nImgW = value; }
200 [Description(
"Specifies the excplicit step size to use.")]
203 get {
return m_fStep; }
204 set { m_fStep = value; }
213 [Description(
"Specifies the explicit step size to use along height. Either the step_h and step_w are used or the step, but not both.")]
216 get {
return m_fStepH; }
217 set { m_fStepH = value; }
226 [Description(
"Specifies the explicit step size to use along width. Either the step_h and step_w are used or the step, but not both.")]
229 get {
return m_fStepW; }
230 set { m_fStepW = value; }
236 [Description(
"Specifies the offset to the top left corner of each cell.")]
239 get {
return m_fOffset; }
240 set { m_fOffset = value; }
249 public override object Load(BinaryReader br,
bool bNewInstance =
true)
306 rgChildren.
Add(
"flip",
flip.ToString());
307 rgChildren.
Add(
"clip",
clip.ToString());
312 rgChildren.
Add(
"img_size",
img_size.Value.ToString());
317 rgChildren.
Add(
"img_h",
img_h.Value.ToString());
319 rgChildren.
Add(
"img_w",
img_w.Value.ToString());
324 rgChildren.
Add(
"step",
step.Value.ToString());
329 rgChildren.
Add(
"step_h",
step_h.Value.ToString());
331 rgChildren.
Add(
"step_w",
step_w.Value.ToString());
334 rgChildren.
Add(
"offset",
offset.ToString());
336 return new RawProto(strName,
"", rgChildren);
351 p.
min_size = rp.FindArray<
float>(
"min_size");
352 p.
max_size = rp.FindArray<
float>(
"max_size");
355 if ((strVal = rp.
FindValue(
"flip")) !=
null)
356 p.
flip =
bool.Parse(strVal);
358 if ((strVal = rp.
FindValue(
"clip")) !=
null)
359 p.
clip =
bool.Parse(strVal);
361 p.
variance = rp.FindArray<
float>(
"variance");
363 if ((strVal = rp.
FindValue(
"img_size")) !=
null)
369 if ((strVal = rp.
FindValue(
"img_h")) !=
null)
370 p.
img_h = uint.Parse(strVal);
372 if ((strVal = rp.
FindValue(
"img_w")) !=
null)
373 p.
img_w = uint.Parse(strVal);
376 if ((strVal = rp.
FindValue(
"step")) !=
null)
382 if ((strVal = rp.
FindValue(
"step_h")) !=
null)
385 if ((strVal = rp.
FindValue(
"step_w")) !=
null)
389 if ((strVal = rp.
FindValue(
"offset")) !=
null)
402 List<float> rgAspectRatios =
new List<float>();
404 rgAspectRatios.Add(1.0f);
409 bool bAlreadyExists =
false;
411 for (
int j = 0; j < rgAspectRatios.Count; j++)
413 if (Math.Abs(fAr - rgAspectRatios[j]) < 1e-6f)
415 bAlreadyExists =
true;
422 rgAspectRatios.Add(fAr);
424 rgAspectRatios.Add(1.0f / fAr);
428 return rgAspectRatios;
442 if (!nNumPriors.HasValue)
446 int nAspectCount = rgAspectRatios.Count;
448 nNumPriors = nMinCount * nAspectCount;
462 rgTopShape[2] = nLayerWid * nLayerHt * nNumPriors.Value * 4;
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.
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
The Utility class provides general utility funtions.
static List< int > Create(int nCount, int nStart, int nInc)
Create a new List and fill it with values starting with start and incrementing by inc.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the PriorBoxParameter.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
float offset
Specifies the offset to the top left corner of each cell.
uint? img_size
Specifies the image size. By default we calculate the img_height, img_width, step_x and step_y based ...
uint? img_h
Specifies the image height. By default we calculate the img_height, img_width, step_x and step_y base...
static PriorBoxParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
static List< int > Reshape(PriorBoxParameter p, int nLayerWid, int nLayerHt, int? nNumPriors=null)
Calculate the reshape size based on the parameters.
List< float > variance
Specifies the variance for adjusting the prior boxes.
static List< float > GetAspectRatios(PriorBoxParameter p)
Return the list of aspect ratios to use based on the parameters.
List< float > max_size
Specifies the maximum box size (in pixels) and is required!
bool flip
Specifies whether or not to flip each aspect ratio. For example, if there is an aspect ratio 'r' we w...
float? step_w
Specifies the explicit step size to use along width.
uint? img_w
Specifies the image width. By default we calculate the img_height, img_width, step_x and step_y based...
override object Load(BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
float? step
Specifies the excplicit step size to use.
float? step_h
Specifies the explicit step size to use along height.
List< float > aspect_ratio
Specifies various aspect ratios. Duplicate ratios are ignored. If none are provided,...
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
PriorBoxParameter()
The constructor.
bool clip
Specifies whether or not to clip the prior so that it is within [0,1].
static CodeType CodeTypeFromString(string str)
Convert a string into a CodeType.
List< float > min_size
Specifies the minimum box size (in pixels) and is required!
CodeType
Defines the encode/decode type.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
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-...