public void LookupFalseTest()
        {
            GroundTruth.CreateGroundTruthLookup();

            string[] imageArray = GroundTruth.GetImageKeys();
            bool     isHealthy  = GroundTruth.Lookup("DSC00041.JPG");

            Assert.IsFalse(isHealthy);
        }
        public void GetImageKeysTest()
        {
            GroundTruth.CreateGroundTruthLookup();

            string[] imageArray  = GroundTruth.GetImageKeys();
            int      numEntries  = imageArray.Length;
            int      numPictures = 1787;

            Assert.IsTrue(numEntries == numPictures);
        }
        public void CreateGroundTruth(Prediction prediction, string label, string source)
        {
            var groundTruth = new GroundTruth();

            groundTruth.Prediction = prediction;
            groundTruth.Label      = label;
            groundTruth.Source     = source;

            var request = new GroundTruthRequest();

            request.GroundTruth = groundTruth;
            var response = this.client.CreateGroundTruth(request);
        }
示例#4
0
        // Attempt AI Prediction:
        public JsonResult OnGetGroundTruth()
        {
            // Get the query string:
            var    queryStringObject = Request.QueryString;
            string queryString       = queryStringObject.ToString();

            // Parse the query string and extract parameters:
            string[] queryParams = queryString.Split("&");
            string   imageURL    = queryParams[1].Replace("imageURL=", "");

            // Attempt to return the response:
            return(new JsonResult(GroundTruth.Lookup(imageURL)));
        }
示例#5
0
        /// <summary>
        /// This is the starting point of the server program. Here we assign the app a configuration and initialize Machine Learning engines.
        /// </summary>
        /// <param name="configuration">An IConfiguration object</param>
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            // Set Firebase URL:
            RestfulDBConnection.FIREBASE_URL = Configuration["FirebaseURL"];

            // Initialize Machine Learning Components:
            MLModel.CreatePredictionEngine();
            GroundTruth.CreateGroundTruthLookup();

            // Get the Machine Learning Warmed Up:
            MLModel.Predict("https://firebasestorage.googleapis.com/v0/b/agricultureai-15ce0.appspot.com/o/DSC00025.JPG?alt=media");
        }
示例#6
0
        public void CreateGroundTruth(Prediction prediction, string label, string source)
        {
            var groundTruth = new GroundTruth
            {
                Prediction = prediction,
                Label      = label,
                Source     = source
            };

            var request = new GroundTruthRequest
            {
                GroundTruth = groundTruth
            };

            this.client.CreateGroundTruth(request);
        }
示例#7
0
        public async Task <bool> CreateGroundTruthAsync(Prediction prediction, string label, string source)
        {
            var groundTruth = new GroundTruth
            {
                Prediction = prediction,
                Label      = label,
                Source     = source
            };

            var request = new GroundTruthRequest
            {
                GroundTruth = groundTruth
            };

            await this.client.CreateGroundTruthAsync(request);

            return(true);
        }
        public void getNumTrueAndFalse()
        {
            int numTrue  = 0;
            int numFalse = 0;

            GroundTruth.CreateGroundTruthLookup();
            string[] imageArray = GroundTruth.GetImageKeys();

            int numImages = imageArray.Length;

            for (int i = 0; i < imageArray.Length; i++)
            {
                if (GroundTruth.Lookup((imageArray[i]).ToString()) == true)
                {
                    numTrue++;
                }
                else
                {
                    numFalse++;
                }
            }

            Assert.IsTrue((numFalse + numTrue) == numImages);
        }
示例#9
0
 internal void AddPrediction(TSolution truth, TSolution prediction)
 {
     GroundTruth.Add(truth);
     Predicted.Add(prediction);
 }
示例#10
0
 // Attempt Getting Image Keys:
 public JsonResult OnGetImageKeys()
 {
     // Attempt to return the response:
     return(new JsonResult(GroundTruth.GetImageKeys()));
 }
示例#11
0
        public static SortedDictionary <String, List <GroundTruth> > buildDataFromFile(string pathFile, string pathDataset)
        {
            string[]    data    = File.ReadAllLines(pathFile);
            string[]    txt     = null;
            string      imgName = null;
            string      dbName  = new DirectoryInfo(pathDataset).Name;
            GroundTruth gt      = null;
            SortedDictionary <String, List <GroundTruth> > groundTruth = new SortedDictionary <string, List <GroundTruth> >();

            MenuService menuService = new MenuService();

            for (int i = 0; i < data.Length; i++)
            {
                if (data[i].CompareTo("") == 0)
                {
                    continue;
                }

                txt = data[i].Split(FileUtils._token);

                if (txt.Length == 1)
                {
                    imgName = txt[0].Trim();


                    i++;

                    while (i < data.Length && data[i].CompareTo("") != 0)
                    {
                        txt = data[i].Split(FileUtils._token);
                        gt  = new GroundTruth();

                        gt._sing._x     = int.Parse(txt[0]);
                        gt._sing._y     = int.Parse(txt[1]);
                        gt._sing._type  = Singularity.stringToSingType(txt[2].Trim());
                        gt._datasetName = dbName;
                        gt._imageName   = imgName;


                        string[] file        = imgName.Split('.');
                        string   rectImgName = string.Format("{0}_{1}_{2}_{3}.{4}", file[0], gt._sing._type.ToString(), gt._sing._x, gt._sing._y, file[1]);
                        string   p           = Path.Combine(pathDataset, gt._sing._type.ToString(), rectImgName);
                        if (File.Exists(p))
                        {
                            gt._sing._image = new Bitmap(p);
                        }
                        else
                        {
                            p = p = Path.Combine(pathDataset, imgName);
                            Bitmap    b    = new Bitmap(p);
                            Rectangle rect = GraphicsUtils.getRectFromSing(gt._sing, b.Width, b.Height);
                            gt._sing._image = b.Clone(rect, b.PixelFormat);
                        }

                        menuService.addGroundTruth(groundTruth, imgName, gt);

                        i++;
                    }
                }
            }

            return(groundTruth);
        }
示例#12
0
        public void addGroundTruth(SortedDictionary <String, List <GroundTruth> > map, string nameImage, GroundTruth g)
        {
            List <GroundTruth> l;

            if (!map.TryGetValue(nameImage, out l))
            {
                map.Add(nameImage, new List <GroundTruth>());
            }

            map[nameImage].Add(g);
        }