예제 #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
파일: Main.cs 프로젝트: exitmouse/drfcsharp
        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
 public PeaksFeature(HogsMaker sh, FeatureApplicationScheme windower)
 {
     SharedHogs = sh;
     Windower = windower;
 }
예제 #6
0
 public MomentFeature(HogsMaker sh, FeatureApplicationScheme windower, int moment)
 {
     SharedHogs = sh;
     Windower = windower;
     Moment = moment;
 }
예제 #7
0
 public RightAngleFeature(HogsMaker sh, FeatureApplicationScheme windower, int num_peaks)
 {
     SharedHogs = sh;
     Windower = windower;
     NumPeaks = num_peaks;
 }