Пример #1
0
 public void Init()
 {
     gm = new GradientArrayMaker(0.5d);
     iws = new ImageWindowScheme(2, 2, 256, 256, 4);
     hm50 = new HogsMaker(gm, 50);
     avg50 = new MomentFeature(hm50, iws, 0);
     second50 = new MomentFeature(hm50, iws, 2);
 }
Пример #2
0
 public void Init()
 {
     gm = new GradientArrayMaker(0.5d);
     iws = new ImageWindowScheme(2, 2, 256, 256, 4);
     hm50 = new HogsMaker(gm, 50);
     pf50 = new PeaksFeature(hm50, iws);
     hm2 = new HogsMaker(gm, 2);
     pf2 = new PeaksFeature(hm2, iws);
 }
Пример #3
0
 public void Init()
 {
     gm = new GradientArrayMaker(0.5d);
     iws = new ImageWindowScheme(2, 2, 256, 256, 4);
     hm50 = new HogsMaker(gm, 50);
     raf50 = new RightAngleFeature(hm50, iws, 2);
     hm2 = new HogsMaker(gm, 2);
     raf2 = new RightAngleFeature(hm2, iws, 1);
 }
Пример #4
0
        public static void Main(string[] args)
        {
            ResourceManager.Builder resources_builder = new ResourceManager.Builder();
            //Set paths here
            ResourceManager resources = resources_builder.Build();

            ImageWindowScheme iws = new ImageWindowScheme(16, 16, 256, 256, 3);
            GradientArrayMaker gm = new GradientArrayMaker(0.5);
            HogsMaker hm = new HogsMaker(gm, 50);
            FeatureSet.Builder feature_set_builder = new FeatureSet.Builder();
            feature_set_builder.AddFeature(new MomentFeature(hm, iws, 2));
            FeatureSet feature_set = feature_set_builder.Build();

            ImageData.Factory idf = new ImageData.Factory(iws.XSites, iws.YSites, feature_set);

            Console.WriteLine("Importing ImageDatas:");
            List<ImageData> images = resources.EachTrainingImage((Bitmap bmp) => {
                    return idf.FromImage(bmp);
                    });
            Console.WriteLine("Importing Classifications:");
            List<Classification> classifications = resources.EachTrainingCSV((StreamReader csv) => {
                    return Classification.FromLabeling(csv, iws.XSites, iws.YSites);
                    });

            ModelFactory.Builder mfb = new ModelFactory.Builder(images, classifications);
            //Set hyperparameters here
            ModelFactory model_factory = mfb.Build();
            Model mfm = model_factory.PseudoLikelihoodTrain();
            Console.WriteLine("Model converged! Estimating image ...");

            string imagename = 192.ToString("D3"); //I still like 192
            ImageData input = resources.UsingTrainingBitmap(imagename+".jpg", bmp => idf.FromImage(bmp));

            Classification out_classed; //See what I did there?
            string inference_algorithm = "logistic";
            if(inference_algorithm == "logistic")
            {
                Console.WriteLine("Inferring with Logistic classifier...");
                out_classed = mfm.LogisticInfer(input);
            }
            else if (inference_algorithm == "map")
            {
                Console.WriteLine("Inferring with MAP classifier...");
                out_classed = mfm.MaximumAPosterioriInfer(input);
            }
            else
            {
                Console.WriteLine("Inferring with ICM classifier...");
                out_classed = mfm.ICMInfer(input);
            }

            resources.UsingOutputCSV("192.txt", (sw) => {
                    sw.Write(out_classed.ToString());
                    });
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DRFCSharp.HogsMaker"/> class.
 /// </summary>
 /// <param name='gm'>
 /// A <see cref="DRFCSharp.GradientArrayMaker"/> object, to be used for HOGs calculations.
 /// </param>
 /// <param name='variance'>
 /// Variance.
 /// </param>
 public HogsMaker(GradientArrayMaker gm, int num_orientations)
 {
     GradientMaker = gm;
     NumOrientations = num_orientations;
 }