/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new NonMaximumSuppressionParameter FromProto(RawProto rp) { NonMaximumSuppressionParameter p = new NonMaximumSuppressionParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("nms_threshold")) != null) { p.nms_threshold = float.Parse(strVal); } if ((strVal = rp.FindValue("top_k")) != null) { p.top_k = int.Parse(strVal); } if ((strVal = rp.FindValue("eta")) != null) { p.eta = float.Parse(strVal); } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new SaltPepperParameter FromProto(RawProto rp) { SaltPepperParameter p = new SaltPepperParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("fraction")) != null) { p.fraction = float.Parse(strVal); } p.value = new List <float>(); RawProtoCollection col = rp.FindChildren("value"); foreach (RawProto rp1 in col) { if ((strVal = rp.FindValue("value")) != null) { p.value.Add(float.Parse(strVal)); } } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new EmitConstraint FromProto(RawProto rp) { EmitConstraint p = new EmitConstraint(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("emit_type")) != null) { switch (strVal) { case "CENTER": p.emit_type = EmitType.CENTER; break; case "MIN_OVERLAP": p.emit_type = EmitType.MIN_OVERLAP; break; default: throw new Exception("Unknown emit_type '" + strVal + "'!"); } } if ((strVal = rp.FindValue("emit_overlap")) != null) { p.emit_overlap = BaseParameter.ParseFloat(strVal); } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new ExpansionParameter FromProto(RawProto rp) { ExpansionParameter p = new ExpansionParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("prob")) != null) { p.prob = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("max_expand_ratio")) != null) { p.max_expand_ratio = BaseParameter.ParseFloat(strVal); } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new NoiseParameter FromProto(RawProto rp) { NoiseParameter p = new NoiseParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("prob")) != null) { p.prob = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("hist_eq")) != null) { p.hist_eq = bool.Parse(strVal); } if ((strVal = rp.FindValue("inverse")) != null) { p.inverse = bool.Parse(strVal); } if ((strVal = rp.FindValue("decolorize")) != null) { p.decolorize = bool.Parse(strVal); } if ((strVal = rp.FindValue("gauss_blur")) != null) { p.gauss_blur = bool.Parse(strVal); } if ((strVal = rp.FindValue("jpeg")) != null) { p.jpeg = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("posterize")) != null) { p.posterize = bool.Parse(strVal); } if ((strVal = rp.FindValue("erode")) != null) { p.erode = bool.Parse(strVal); } if ((strVal = rp.FindValue("saltpepper")) != null) { p.saltpepper = bool.Parse(strVal); } RawProto rp1 = rp.FindChild("saltpepper_param"); if (rp1 != null) { p.saltpepper_param = SaltPepperParameter.FromProto(rp1); } if ((strVal = rp.FindValue("clahe")) != null) { p.clahe = bool.Parse(strVal); } if ((strVal = rp.FindValue("convert_to_hsv")) != null) { p.convert_to_hsv = bool.Parse(strVal); } if ((strVal = rp.FindValue("convert_to_lab")) != null) { p.convert_to_lab = bool.Parse(strVal); } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new ResizeParameter FromProto(RawProto rp) { ResizeParameter p = new ResizeParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("active")) != null) { p.Active = bool.Parse(strVal); } if ((strVal = rp.FindValue("prob")) != null) { p.prob = float.Parse(strVal); } if ((strVal = rp.FindValue("resize_mode")) != null) { switch (strVal) { case "WARP": p.resize_mode = ResizeMode.WARP; break; case "FIT_SMALL_SIZE": p.resize_mode = ResizeMode.FIT_SMALL_SIZE; break; case "FIT_LARGE_SIZE_AND_PAD": p.resize_mode = ResizeMode.FIT_LARGE_SIZE_AND_PAD; break; default: throw new Exception("Unknown resize_mode '" + strVal + "'!"); } } if ((strVal = rp.FindValue("height")) != null) { p.height = uint.Parse(strVal); } if ((strVal = rp.FindValue("width")) != null) { p.width = uint.Parse(strVal); } if ((strVal = rp.FindValue("height_scale")) != null) { p.height_scale = uint.Parse(strVal); } if ((strVal = rp.FindValue("width_scale")) != null) { p.width_scale = uint.Parse(strVal); } if ((strVal = rp.FindValue("pad_mode")) != null) { switch (strVal) { case "CONSTANT": p.pad_mode = PadMode.CONSTANT; break; case "MIRRORED": p.pad_mode = PadMode.MIRRORED; break; case "REPEAT_NEAREST": p.pad_mode = PadMode.REPEAT_NEAREST; break; default: throw new Exception("Unknown pad_mode '" + strVal + "'!"); } } p.pad_value = new List <float>(); RawProtoCollection col = rp.FindChildren("pad_value"); foreach (RawProto rp1 in col) { if ((strVal = rp.FindValue("pad_value")) != null) { p.pad_value.Add(float.Parse(strVal)); } } p.interp_mode = new List <InterpMode>(); RawProtoCollection col1 = rp.FindChildren("interp_mode"); foreach (RawProto pr1 in col1) { strVal = pr1.Value; switch (strVal) { case "LINEAR": p.interp_mode.Add(InterpMode.LINEAR); break; case "AREA": p.interp_mode.Add(InterpMode.AREA); break; case "NEAREST": p.interp_mode.Add(InterpMode.NEAREST); break; case "CUBIC": p.interp_mode.Add(InterpMode.CUBIC); break; case "LANCZOS4": p.interp_mode.Add(InterpMode.LANCZOS4); break; default: throw new Exception("Unknown interp_mode '" + strVal + "'!"); } } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new SaveOutputParameter FromProto(RawProto rp) { SaveOutputParameter p = new SaveOutputParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("output_directory")) != null) { p.output_directory = strVal; } if ((strVal = rp.FindValue("output_name_prefix")) != null) { p.output_name_prefix = strVal; } if ((strVal = rp.FindValue("output_format")) != null) { if (strVal == OUTPUT_FORMAT.VOC.ToString()) { p.output_format = OUTPUT_FORMAT.VOC; } else if (strVal == OUTPUT_FORMAT.COCO.ToString()) { p.output_format = OUTPUT_FORMAT.COCO; } else { throw new Exception("Unknown output_format '" + strVal + "'!"); } } if ((strVal = rp.FindValue("label_map_file")) != null) { p.label_map_file = strVal; } if ((strVal = rp.FindValue("name_size_file")) != null) { p.name_size_file = strVal; } if ((strVal = rp.FindValue("num_test_image")) != null) { p.num_test_image = uint.Parse(strVal); } RawProto rpResize = rp.FindChild("resize_param"); if (rpResize != null) { p.resize_param = ResizeParameter.FromProto(rpResize); } return(p); }
/// <summary> /// Parses the parameter from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto to parse.</param> /// <returns>A new instance of the parameter is returned.</returns> public static new DistortionParameter FromProto(RawProto rp) { DistortionParameter p = new DistortionParameter(false); string strVal; RawProto rpOption = rp.FindChild("option"); if (rpOption != null) { ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption)); } if ((strVal = rp.FindValue("active")) != null) { p.Active = bool.Parse(strVal); } if ((strVal = rp.FindValue("brightness_prob")) != null) { p.brightness_prob = float.Parse(strVal); } if ((strVal = rp.FindValue("brightness_delta")) != null) { p.brightness_delta = float.Parse(strVal); } if ((strVal = rp.FindValue("contrast_prob")) != null) { p.contrast_prob = float.Parse(strVal); } if ((strVal = rp.FindValue("contrast_lower")) != null) { p.contrast_lower = float.Parse(strVal); } if ((strVal = rp.FindValue("contrast_upper")) != null) { p.contrast_upper = float.Parse(strVal); } if ((strVal = rp.FindValue("saturation_prob")) != null) { p.saturation_prob = float.Parse(strVal); } if ((strVal = rp.FindValue("saturation_lower")) != null) { p.saturation_lower = float.Parse(strVal); } if ((strVal = rp.FindValue("saturation_upper")) != null) { p.saturation_upper = float.Parse(strVal); } if ((strVal = rp.FindValue("random_order_prob")) != null) { p.random_order_prob = float.Parse(strVal); } if ((strVal = rp.FindValue("use_gpu")) != null) { p.use_gpu = bool.Parse(strVal); } if ((strVal = rp.FindValue("random_seed")) != null) { p.random_seed = long.Parse(strVal); } return(p); }