Beispiel #1
0
        /// <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);
        }
        /** @copydoc LayerParameterBase::Copy */
        public override void Copy(LayerParameterBase src)
        {
            MultiBoxLossParameter p = src as MultiBoxLossParameter;

            m_locLossType              = p.loc_loss_type;
            m_confLossType             = p.conf_loss_type;
            m_fLocWeight               = p.loc_weight;
            m_nNumClasses              = p.num_classes;
            m_bShareLocation           = p.share_location;
            m_matchType                = p.match_type;
            m_fOverlapThreshold        = p.overlap_threshold;
            m_nBackgroundLabelId       = p.background_label_id;
            m_bUseDifficultGt          = p.use_difficult_gt;
            m_bDoNegMining             = p.do_neg_mining;
            m_fNegPosRatio             = p.neg_pos_ratio;
            m_fNegOverlap              = p.neg_overlap;
            m_codeType                 = p.code_type;
            m_bEncodeVarianceInTarget  = p.encode_variance_in_target;
            m_bMapObjectToAgnostic     = p.map_object_to_agnostic;
            m_bIgnoreCrossBoundaryBbox = p.ignore_cross_boundary_bbox;
            m_bBpInside                = p.bp_inside;
            m_miningType               = p.mining_type;
            m_nmsParam                 = p.nms_param.Clone();
            m_nSampleSize              = p.sample_size;
            m_bUsePriorForNms          = p.use_prior_for_nms;
            m_bUsePriorForMatching     = p.use_prior_for_matching;
        }
Beispiel #3
0
        /// <summary>
        /// Copy the object.
        /// </summary>
        /// <param name="src">The copy is placed in this parameter.</param>
        public override void Copy(OptionalParameter src)
        {
            base.Copy(src);

            if (src is NonMaximumSuppressionParameter)
            {
                NonMaximumSuppressionParameter p = (NonMaximumSuppressionParameter)src;
                m_fNmsThreshold = p.nms_threshold;
                m_nTopK         = p.top_k;
                m_fEta          = p.eta;
            }
        }
        /// <summary>
        /// Copy on parameter to another.
        /// </summary>
        /// <param name="src">Specifies the parameter to copy.</param>
        public override void Copy(LayerParameterBase src)
        {
            DetectionOutputParameter p = (DetectionOutputParameter)src;

            m_nNumClasses              = p.m_nNumClasses;
            m_bShareLocation           = p.m_bShareLocation;
            m_nBackgroundLabelId       = p.m_nBackgroundLabelId;
            m_nmsParam                 = p.m_nmsParam.Clone();
            m_saveOutputParam          = p.save_output_param.Clone() as SaveOutputParameter;
            m_codeType                 = p.m_codeType;
            m_bVarianceEncodedInTarget = p.m_bVarianceEncodedInTarget;
            m_nKeepTopK                = p.m_nKeepTopK;
            m_fConfidenceThreshold     = p.m_fConfidenceThreshold;
            m_bVisualize               = p.m_bVisualize;
            m_fVisualizeThreshold      = p.m_fVisualizeThreshold;
            m_strSaveFile              = p.m_strSaveFile;
        }
        /// <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 NonMaximumSuppressionParameter FromProto(RawProto rp)
        {
            NonMaximumSuppressionParameter p = new NonMaximumSuppressionParameter();
            string strVal;

            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 MultiBoxLossParameter FromProto(RawProto rp)
        {
            MultiBoxLossParameter p = new MultiBoxLossParameter();
            string strVal;

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

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

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

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

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

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

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

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

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

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

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

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

            if ((strVal = rp.FindValue("code_type")) != null)
            {
                p.code_type = PriorBoxParameter.CodeTypeFromString(strVal);
            }

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

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

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

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

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

            RawProto rpNms = rp.FindChild("nms_param");

            if (rpNms != null)
            {
                p.nms_param = NonMaximumSuppressionParameter.FromProto(rpNms);
            }

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

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

            return(p);
        }
 /// <summary>
 /// Copy the object.
 /// </summary>
 /// <param name="src">The copy is placed in this parameter.</param>
 public void Copy(NonMaximumSuppressionParameter src)
 {
     m_fNmsThreshold = src.nms_threshold;
     m_nTopK         = src.top_k;
     m_fEta          = src.eta;
 }
        /// <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 DetectionOutputParameter FromProto(RawProto rp)
        {
            DetectionOutputParameter p = new DetectionOutputParameter();
            string strVal;

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

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

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

            RawProto rpNms = rp.FindChild("nms_param");

            if (rpNms != null)
            {
                p.nms_param = NonMaximumSuppressionParameter.FromProto(rpNms);
            }

            RawProto rpSave = rp.FindChild("save_output_param");

            if (rpSave != null)
            {
                p.save_output_param = SaveOutputParameter.FromProto(rpSave);
            }

            if ((strVal = rp.FindValue("code_type")) != null)
            {
                if (strVal == PriorBoxParameter.CodeType.CENTER_SIZE.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CENTER_SIZE;
                }
                else if (strVal == PriorBoxParameter.CodeType.CORNER.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CORNER;
                }
                else if (strVal == PriorBoxParameter.CodeType.CORNER_SIZE.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CORNER_SIZE;
                }
                else
                {
                    throw new Exception("Unknown PriorBoxParameter.CodeType '" + strVal + "'!");
                }
            }

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

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

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

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

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

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

            return(p);
        }