示例#1
0
 public ActionResult PredictMnist(string imageRaw)
 {
     try
     {
         var image = ImageFunctions.Base64ToImage(imageRaw);
         image = ImageFunctions.Resize(image, 28, 28);
         var    directory       = AppDomain.CurrentDomain.BaseDirectory;
         var    path            = Path.Combine(directory, "CNNModel");
         string outputModelPath = Path.Combine(path, "model.mod");
         var    label           = CNNManager.TestItems(outputModelPath, image);
         return(new JsonResult()
         {
             Data = new { Status = "Success", Message = "Complete", Label = label },
             JsonRequestBehavior = JsonRequestBehavior.DenyGet
         });
     }
     catch (Exception ex)
     {
         return(new JsonResult()
         {
             Data = new { Status = "Failure", Message = "Error making prediction." },
             JsonRequestBehavior = JsonRequestBehavior.DenyGet
         });
     }
 }
示例#2
0
        public static void RunCNN()
        {
            //Get images
            var    directory       = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            var    path            = Path.Combine(directory, "training-set");
            var    virtualFolder   = new Uri(path).LocalPath;
            string outputModelPath = Path.Combine(path, "model.mod");

            CNNManager.TrainCNN(path, outputModelPath);
        }