Exemple #1
0
        private async void ExecuteOpen(object param)
        {
            ObservableModelPrediction.Clear();
            AvailableClasses.Clear();
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    IsRunning = true;
                    (var OldImages, var NewImages) = await client.PostOld(fbd.SelectedPath, cts);

                    OldImages.ForEach(delegate(PredictionResponse prs) { AddPrecomputedPrediction(new ModelPrediction(prs.ClassName, prs.Proba, prs.FilePath, Convert.FromBase64String(prs.Image))); });
                    var NewImagesResults = await client.GetNew(NewImages, cts);

                    NewImagesResults.ForEach(delegate(PredictionResult pr) { AddPrediction(pr); });
                    IsRunning = false;
                }
                catch (TaskCanceledException tce)
                {
                    MessageBox.Show("Tasks were cancelled");
                }
                catch (Exception e)
                {
                    MessageBox.Show("Prediction failed!");
                }
            }
        }
Exemple #2
0
 private void ExecuteClear(object param)
 {
     ObservableModelPrediction.Clear();
     AvailableClasses.Clear();
     try
     {
         client.Delete();
     }
     catch (Exception e)
     {
         MessageBox.Show("Clearing DataBase failed!");
     }
 }
Exemple #3
0
        private void AddPrediction(PredictionResult pr)
        {
            dispatcher.BeginInvoke(new Action(() =>
            {
                ObservableModelPrediction.Add(new ModelPrediction(pr));
                var buf = AvailableClasses.Where(x => x.Item1 == pr.ClassName).FirstOrDefault();

                if (buf != null)
                {
                    AvailableClasses[AvailableClasses.IndexOf(buf)] = new Tuple <string, int>(buf.Item1, buf.Item2 + 1);
                }
                else
                {
                    AvailableClasses.Add(new Tuple <string, int>(pr.ClassName, 1));
                }
            }));
        }