MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SaveOutputParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7using System.IO;
8
9namespace MyCaffe.param.ssd
10{
18 [Serializable]
19 [TypeConverter(typeof(ExpandableObjectConverter))]
21 {
22 string m_strOutputDirectory;
23 string m_strOutputNamePrefix;
24 OUTPUT_FORMAT m_outputFormat = OUTPUT_FORMAT.VOC;
25 string m_strLabelMapFile;
26 string m_strNameSizeFile;
27 uint? m_nNumTestImage = null;
28 ResizeParameter m_resizeParam = null;
29
33 public enum OUTPUT_FORMAT
34 {
38 VOC,
42 COCO,
46 ILSVRC
47 }
48
53 public SaveOutputParameter(bool bActive) : base(bActive)
54 {
55 }
56
60 [Description("Specifies output directory, if not empty, the results will be saved.")]
61 public string output_directory
62 {
63 get { return m_strOutputDirectory; }
64 set { m_strOutputDirectory = value; }
65 }
66
70 [Description("Specifies output name prefix.")]
71 public string output_name_prefix
72 {
73 get { return m_strOutputNamePrefix; }
74 set { m_strOutputNamePrefix = value; }
75 }
76
80 [Description("Specifies output name prefix.")]
82 {
83 get { return m_outputFormat; }
84 set { m_outputFormat = value; }
85 }
86
90 [Description("Optionally, specifies output label map file.")]
91 public string label_map_file
92 {
93 get { return m_strLabelMapFile; }
94 set { m_strLabelMapFile = value; }
95 }
96
106 [Description("Optionally, specifies output name size file.")]
107 public string name_size_file
108 {
109 get { return m_strNameSizeFile; }
110 set { m_strNameSizeFile = value; }
111 }
112
118 [Description("Specifies the number of test images, which can be less than the name_size_file line count.")]
119 public uint? num_test_image
120 {
121 get { return m_nNumTestImage; }
122 set { m_nNumTestImage = value; }
123 }
124
128 [Description("Specifies the resize parameter used in saving the data.")]
130 {
131 get { return m_resizeParam; }
132 set { m_resizeParam = value; }
133 }
134
141 public SaveOutputParameter Load(BinaryReader br, bool bNewInstance = true)
142 {
143 RawProto proto = RawProto.Parse(br.ReadString());
145
146 if (!bNewInstance)
147 Copy(p);
148
149 return p;
150 }
151
156 public override void Copy(OptionalParameter src)
157 {
158 base.Copy(src);
159
160 if (src is SaveOutputParameter)
161 {
163
164 m_strOutputDirectory = p.m_strOutputDirectory;
165 m_strOutputNamePrefix = p.m_strOutputNamePrefix;
166 m_outputFormat = p.m_outputFormat;
167 m_strLabelMapFile = p.m_strLabelMapFile;
168 m_strNameSizeFile = p.m_strNameSizeFile;
169 m_nNumTestImage = p.m_nNumTestImage;
170
171 m_resizeParam = null;
172 if (p.resize_param != null)
173 m_resizeParam = p.resize_param.Clone();
174 }
175 }
176
182 {
184 p.Copy(this);
185 return p;
186 }
187
193 public override RawProto ToProto(string strName)
194 {
195 RawProto rpBase = base.ToProto("option");
196 RawProtoCollection rgChildren = new RawProtoCollection();
197
198 rgChildren.Add(rpBase);
199 rgChildren.Add(new RawProto("output_directory", m_strOutputDirectory));
200 rgChildren.Add(new RawProto("output_name_prefix", m_strOutputNamePrefix));
201 rgChildren.Add(new RawProto("output_format", m_outputFormat.ToString()));
202 rgChildren.Add(new RawProto("label_map_file", m_strLabelMapFile));
203 rgChildren.Add(new RawProto("name_size_file", m_strNameSizeFile));
204
205 if (m_nNumTestImage.HasValue)
206 rgChildren.Add(new RawProto("num_test_image", m_nNumTestImage.Value.ToString()));
207
208 if (resize_param != null)
209 rgChildren.Add(resize_param.ToProto("resize_param"));
210
211 return new RawProto(strName, "", rgChildren);
212 }
213
220 {
222 string strVal;
223
224 RawProto rpOption = rp.FindChild("option");
225 if (rpOption != null)
226 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
227
228 if ((strVal = rp.FindValue("output_directory")) != null)
229 p.output_directory = strVal;
230
231 if ((strVal = rp.FindValue("output_name_prefix")) != null)
232 p.output_name_prefix = strVal;
233
234 if ((strVal = rp.FindValue("output_format")) != null)
235 {
236 if (strVal == OUTPUT_FORMAT.VOC.ToString())
238 else if (strVal == OUTPUT_FORMAT.COCO.ToString())
240 else
241 throw new Exception("Unknown output_format '" + strVal + "'!");
242 }
243
244 if ((strVal = rp.FindValue("label_map_file")) != null)
245 p.label_map_file = strVal;
246
247 if ((strVal = rp.FindValue("name_size_file")) != null)
248 p.name_size_file = strVal;
249
250 if ((strVal = rp.FindValue("num_test_image")) != null)
251 p.num_test_image = uint.Parse(strVal);
252
253 RawProto rpResize = rp.FindChild("resize_param");
254 if (rpResize != null)
256
257 return p;
258 }
259 }
260}
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 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 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.
Specifies the parameters for the SaveOutputLayer.
OUTPUT_FORMAT output_format
Specifies the output format.
SaveOutputParameter Load(BinaryReader br, bool bNewInstance=true)
Load the and return a new ResizeParameter.
string output_directory
Specifies the output directory - if not empty, the results will be saved.
string name_size_file
Optionally, specifies the output name size file.
ResizeParameter resize_param
Specifies the resize parameter used in saving the data.
static new SaveOutputParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
string label_map_file
Optionally, specifies the output label map file.
OUTPUT_FORMAT
Defines the output format.
string output_name_prefix
Specifies the output name prefix.
SaveOutputParameter Clone()
Return a copy of this object.
override void Copy(OptionalParameter src)
Copy the source object.
SaveOutputParameter(bool bActive)
The constructor.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
uint? num_test_image
Specifies the number of test images.
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