Esempio n. 1
0
        public static ModelOutput Predict(ModelInput input)
        {
            string    modelPath;
            MLContext mlContext = new MLContext();

            try
            {
                modelPath = AppDomain.CurrentDomain.BaseDirectory + "MLModel.zip";
                ITransformer mlModel    = mlContext.Model.Load(modelPath, out var modelInputSchema);
                var          predEngine = mlContext.Model.CreatePredictionEngine <ModelInput, ModelOutput>(mlModel);

                ModelOutput result = predEngine.Predict(input);
                return(result);
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Model.zip file missing. Please choose another.", "Missing Model File", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                modelPath = FileNameGetter.returnModelZip_filename();

                ITransformer mlModel    = mlContext.Model.Load(modelPath, out var modelInputSchema);
                var          predEngine = mlContext.Model.CreatePredictionEngine <ModelInput, ModelOutput>(mlModel);

                ModelOutput result = predEngine.Predict(input);
                return(result);
            }
        }
Esempio n. 2
0
        private void btnPredict_Click(object sender, RoutedEventArgs e)
        {
            DogPredict.Clear();
            var    input = new ModelInput();
            string path  = FileNameGetter.return_filename();

            img.image_setter(imgPicture, path);
            img.image_setter(input, path);

            ModelOutput prediction = ConsumeModel.Predict(input);
            Prediction  p          = new Prediction(prediction.Score);

            LogWriter.Log(p.getDogList());

            DogPlots.Add(new Plot(p.getDogList()[0].GetProbability(), DateTime.Now));

            foreach (Dog d in p.dogList)
            {
                DogPredict.Add(d);
            }

            theGrid.Visibility            = Visibility.Visible;
            theGrid.Columns[2].Visibility = Visibility.Hidden;
            theGrid.Columns[3].Visibility = Visibility.Hidden;
            theGrid.Columns[4].Visibility = Visibility.Hidden;

            hfr.InsertIntoColumnsList(p.dogList[0].Breed_Name);

            bool newBreed = true;

            foreach (BarColumn b in CurrentBreeds)
            {
                if (b.breedLabel == p.dogList[0].Breed_Name)
                {
                    b.breedFreq += 1;
                    newBreed     = false;
                }
            }

            if (newBreed)
            {
                CurrentBreeds.Add(new BarColumn(p.dogList[0].Breed_Name));
            }
        }
Esempio n. 3
0
        static BreedList()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "Breeds.csv";

            if (File.Exists(path))
            {
                loadList(path);
            }
            else
            {
                MessageBoxResult x = MessageBox.Show("Select Breed.csv ", "Missing Breed List File", MessageBoxButton.OKCancel, MessageBoxImage.Error);

                if (x == MessageBoxResult.OK)
                {
                    loadList(FileNameGetter.returnCSV_filename());
                }
                else if (x == MessageBoxResult.Cancel)
                {
                    System.Environment.Exit(0);
                }
            }
        }