/** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            TransformationParameter p = (TransformationParameter)src;

            m_bUseImageDbMean          = p.m_bUseImageDbMean;
            m_bForceColor              = p.m_bForceColor;
            m_bForceGray               = p.m_bForceGray;
            m_bMirror                  = p.m_bMirror;
            m_dfScale                  = p.m_dfScale;
            m_scaleOperator            = p.m_scaleOperator;
            m_nCropSize                = p.m_nCropSize;
            m_rgMeanValue              = Utility.Clone <double>(p.m_rgMeanValue);
            m_dfForcedPositiveRangeMax = p.m_dfForcedPositiveRangeMax;
            m_nRandomSeed              = p.m_nRandomSeed;
            m_strMeanFile              = p.m_strMeanFile;
            m_colorOrder               = p.m_colorOrder;

            m_resize         = (p.resize_param == null) ? null : p.resize_param.Clone();
            m_noise          = (p.noise_param == null) ? null : p.noise_param.Clone();
            m_distortion     = (p.distortion_param == null) ? null : p.distortion_param.Clone();
            m_expansion      = (p.expansion_param == null) ? null : p.expansion_param.Clone();
            m_emitConstraint = (p.emit_constraint == null) ? null : p.emit_constraint.Clone();

            if (p.mask_param != null)
            {
                m_mask = p.mask_param.Clone();
            }

            if (p.label_mapping != null)
            {
                m_labelMapping = p.label_mapping.Clone();
            }
        }
示例#2
0
 /// <summary>
 /// The ApplyNoise method applies the noise policy to the Blob.
 /// </summary>
 /// <param name="b">Specifies the blob for which noise is to be added.</param>
 /// <param name="p">Specifies the NoiseParameter that defines the noise policy.</param>
 /// <remarks>
 /// NOTE: This method is not yet complete.
 /// </remarks>
 public void ApplyNoise(Blob <T> b, NoiseParameter p)
 {
     m_log.WriteLine("WARNING: noise application not yet implemented.");
 }
        /// <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 TransformationParameter FromProto(RawProto rp)
        {
            string strVal;
            TransformationParameter p = new TransformationParameter();

            if ((strVal = rp.FindValue("scale")) != null)
            {
                p.scale = ParseDouble(strVal);
            }

            if ((strVal = rp.FindValue("scale_operator")) != null)
            {
                if (strVal == SCALE_OPERATOR.MUL.ToString())
                {
                    p.scale_operator = SCALE_OPERATOR.MUL;
                }
                else if (strVal == SCALE_OPERATOR.POW.ToString())
                {
                    p.scale_operator = SCALE_OPERATOR.POW;
                }
                else
                {
                    p.scale_operator = SCALE_OPERATOR.NONE;
                }
            }
            else
            {
                p.scale_operator = null;
            }

            if ((strVal = rp.FindValue("mirror")) != null)
            {
                p.mirror = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("crop_size")) != null)
            {
                p.crop_size = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("use_image_mean")) != null ||
                (strVal = rp.FindValue("use_imagedb_mean")) != null)
            {
                p.use_imagedb_mean = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.use_imagedb_mean = true;
            }

            p.mean_value = rp.FindArray <double>("mean_value");

            if ((strVal = rp.FindValue("force_color")) != null)
            {
                p.force_color = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_gray")) != null)
            {
                p.force_gray = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_positive_range_max")) != null)
            {
                p.forced_positive_range_max = ParseDouble(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.mean_file = strVal;
            }

            if ((strVal = rp.FindValue("color_order")) != null)
            {
                if (strVal == COLOR_ORDER.BGR.ToString())
                {
                    p.color_order = COLOR_ORDER.BGR;
                }
                else
                {
                    p.color_order = COLOR_ORDER.RGB;
                }
            }

            RawProto rpResize = rp.FindChild("resize_param");

            if (rpResize != null)
            {
                p.resize_param = ResizeParameter.FromProto(rpResize);
            }
            else
            {
                p.resize_param = null;
            }

            RawProto rpNoise = rp.FindChild("noise_param");

            if (rpNoise != null)
            {
                p.noise_param = NoiseParameter.FromProto(rpNoise);
            }
            else
            {
                p.noise_param = null;
            }

            RawProto rpDistort = rp.FindChild("distortion_param");

            if (rpDistort != null)
            {
                p.distortion_param = DistortionParameter.FromProto(rpDistort);
            }

            RawProto rpExpand = rp.FindChild("expansion_param");

            if (rpExpand != null)
            {
                p.expansion_param = ExpansionParameter.FromProto(rpExpand);
            }
            else
            {
                p.expansion_param = null;
            }

            RawProto rpEmitCon = rp.FindChild("emit_constraint");

            if (rpEmitCon != null)
            {
                p.emit_constraint = EmitConstraint.FromProto(rpEmitCon);
            }
            else
            {
                p.emit_constraint = null;
            }

            RawProto rpMask = rp.FindChild("mask_param");

            if (rpMask != null)
            {
                p.mask_param = MaskParameter.FromProto(rpMask);
            }

            RawProto rpLabelMapping = rp.FindChild("label_mapping");

            if (rpLabelMapping != null)
            {
                p.label_mapping = DataLabelMappingParameter.FromProto(rpLabelMapping);
            }

            return(p);
        }
示例#4
0
 /// <summary>
 /// The ApplyNoise method applies the noise policy to the SimpleDatum.
 /// </summary>
 /// <param name="sd">Specifies the SimpleDatum for which noise is to be added.</param>
 /// <param name="p">Specifies the NoiseParameter that defines the noise policy.</param>
 /// <remarks>
 /// NOTE: This method is not yet complete.
 /// </remarks>
 public SimpleDatum ApplyNoise(SimpleDatum sd, NoiseParameter p)
 {
     m_log.WriteLine("WARNING: noise application not yet implemented.");
     return(sd);
 }
        /// <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 TransformationParameter FromProto(RawProto rp)
        {
            string strVal;
            TransformationParameter p = new TransformationParameter();

            if ((strVal = rp.FindValue("scale")) != null)
            {
                p.scale = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mirror")) != null)
            {
                p.mirror = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("crop_size")) != null)
            {
                p.crop_size = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("use_image_mean")) != null ||
                (strVal = rp.FindValue("use_imagedb_mean")) != null)
            {
                p.use_imagedb_mean = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.use_imagedb_mean = true;
            }

            p.mean_value = rp.FindArray <double>("mean_value");

            if ((strVal = rp.FindValue("force_color")) != null)
            {
                p.force_color = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_gray")) != null)
            {
                p.force_gray = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_positive_range_max")) != null)
            {
                p.forced_positive_range_max = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.mean_file = strVal;
            }

            if ((strVal = rp.FindValue("color_order")) != null)
            {
                if (strVal == COLOR_ORDER.BGR.ToString())
                {
                    p.color_order = COLOR_ORDER.BGR;
                }
                else
                {
                    p.color_order = COLOR_ORDER.RGB;
                }
            }

            RawProto rpResize = rp.FindChild("resize_param");

            p.resize_param = (rpResize != null) ? ResizeParameter.FromProto(rpResize) : null;

            RawProto rpNoise = rp.FindChild("noise_param");

            p.noise_param = (rpNoise != null) ? NoiseParameter.FromProto(rpNoise) : null;

            RawProto rpDistort = rp.FindChild("distortion_param");

            p.distortion_param = (rpDistort != null) ? DistortionParameter.FromProto(rpDistort) : null;

            RawProto rpExpand = rp.FindChild("expansion_param");

            p.expansion_param = (rpExpand != null) ? ExpansionParameter.FromProto(rpExpand) : null;

            RawProto rpEmitCon = rp.FindChild("emit_constraint");

            p.emit_constraint = (rpEmitCon != null) ? EmitConstraint.FromProto(rpEmitCon) : null;

            return(p);
        }