コード例 #1
0
 /// <summary>
 /// Relabels all datasets using a label mapping collection.
 /// </summary>
 /// <param name="col">Specifies the label mapping collection.</param>
 public void Relabel(LabelMappingCollection col)
 {
     foreach (DatasetEx ds in m_rgDatasets)
     {
         ds.Relabel(col);
     }
 }
コード例 #2
0
        /// <summary>
        /// Applies the label mapping to the image set.
        /// </summary>
        /// <param name="col"></param>
        public void Relabel(LabelMappingCollection col)
        {
            foreach (SimpleDatum sd in m_rgImages)
            {
                sd.SetLabel(col.MapLabel(sd.OriginalLabel));
            }

            ReloadLabelSets();
        }
コード例 #3
0
ファイル: LabelMapping.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Returns a copy of the label mapping collection.
        /// </summary>
        /// <returns></returns>
        public LabelMappingCollection Clone()
        {
            LabelMappingCollection col = new LabelMappingCollection();

            foreach (LabelMapping m in m_rgMappings)
            {
                col.Add(m.Clone());
            }

            return(col);
        }
コード例 #4
0
ファイル: LabelMapping.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Compares one label mapping collection to another.
        /// </summary>
        /// <param name="col">Specifies the other collection to compare.</param>
        /// <returns>If the two collections are the same, <i>true</i> is returned, otherwise <i>false</i> is returned.</returns>
        public bool Compare(LabelMappingCollection col)
        {
            Sort();
            col.Sort();

            string strA = ToString();
            string strB = col.ToString();

            if (strA == strB)
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
 /// <summary>
 /// Relabels both the testing and training image sets using the label mapping collection.
 /// </summary>
 /// <param name="col">Specifies the label mapping collection.</param>
 public void Relabel(LabelMappingCollection col)
 {
     m_TestingImages.Relabel(col);
     m_TrainingImages.Relabel(col);
 }
コード例 #6
0
ファイル: LabelMapping.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Parses a list of strings where each string is a label mapping.
        /// </summary>
        /// <param name="rgstrMappings">Specifies the list of label mapping strings.</param>
        /// <returns>The new LabelMappingCollection is returned.</returns>
        public static LabelMappingCollection Parse(List <string> rgstrMappings)
        {
            LabelMappingCollection col             = new LabelMappingCollection();
            List <string>          rgstrSeparators = new List <string>()
            {
                "->"
            };

            foreach (string strMapping in rgstrMappings)
            {
                string[] rgstr = strMapping.Split(rgstrSeparators.ToArray(), StringSplitOptions.RemoveEmptyEntries);

                if (rgstr.Length != 2)
                {
                    throw new Exception("Each label mapping should have the format 'original->new_label'.");
                }

                if (rgstr[0].Length == 0 || rgstr[1].Length == 0)
                {
                    throw new Exception("Each label mapping should have the format 'original->new_label'.");
                }

                string str1 = rgstr[0].Trim('\"');
                string str2 = rgstr[1].Trim('\"');
                int?   nConditionBoostEquals = null;
                int?   nConditionFalse       = null;

                rgstr = str2.Split('?');
                if (rgstr.Length > 1)
                {
                    str2 = rgstr[0].Trim();

                    string strCondition = "";
                    string strRightSide = rgstr[1].Trim();
                    rgstr = strRightSide.Split(',');

                    if (rgstr.Length == 2)
                    {
                        string str3 = rgstr[0].Trim();
                        if (str3.Length > 0)
                        {
                            nConditionFalse = int.Parse(str3);
                        }

                        strCondition = rgstr[1].Trim();
                    }
                    else if (rgstr.Length == 1)
                    {
                        strCondition = rgstr[0].Trim();
                    }
                    else
                    {
                        throw new Exception("Invalid mapping format! Expected format <true_int>?<false_int>,boost=<int>");
                    }

                    rgstr = strCondition.Split('=');

                    if (rgstr.Length != 2 || rgstr[0].Trim().ToLower() != "boost")
                    {
                        throw new Exception("Invalid boost condition!  Expected format = ?boost=<int>");
                    }

                    nConditionBoostEquals = int.Parse(rgstr[1].Trim());
                }

                col.Add(new LabelMapping(int.Parse(str1), int.Parse(str2), nConditionBoostEquals, nConditionFalse));
            }

            return(col);
        }