示例#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
         });
     }
 }