public bool IsToxic(string text)
        {
            ModelOutput result = ModelConsumer.Predict(new ModelInput
            {
                SentimentText = text
            });

            return(result.Prediction == "1");
        }
예제 #2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            var url           = txtImageUrl.Text;
            var imageFilePath = Path.GetTempFileName();

            DownloadImage(url, imageFilePath);

            ResizeImage(imageFilePath);

            var consumer = new ModelConsumer();
            var response = consumer.PredictObjects(imageFilePath);

            RenderResult(imageFilePath, response);
        }
 public IActionResult Get([FromQuery] List <uint> idList, int maxPrediction = 1)
 {
     try
     {
         ModelConsumer modelConsumer = new ModelConsumer(ModelBuilder.GetFullPath(ModelTrainer.CommonConstant.MODEL_FILE_NAME));
         var           result        = modelConsumer.Predict(idList, maxPrediction);
         return(Ok(new ApiResult()
         {
             Code = ResultCode.Success,
             Data = result,
             Message = ResultCode.Success.DisplayName()
         }));
     }
     catch (Exception e)
     {
         return(Error(new ApiResult()
         {
             Code = ResultCode.UnknownError,
             Message = ResultCode.UnknownError.DisplayName() + e.Message
         }));
     }
 }
 public IActionResult Get(uint id)
 {
     try
     {
         ModelConsumer modelConsumer = new ModelConsumer(ModelBuilder.GetFullPath(ModelTrainer.CommonConstant.MODEL_FILE_NAME));
         var           top5          = modelConsumer.Predict(id);
         return(Ok(new ApiResult()
         {
             Code = ResultCode.Success,
             Message = ResultCode.Success.DisplayName(),
             Data = top5
         }));
     }
     catch (Exception e)
     {
         return(Error(new ApiResult()
         {
             Code = ResultCode.UnknownError,
             Message = ResultCode.UnknownError.DisplayName() + e.Message
         }));
     }
 }
예제 #5
0
 public ModelOutput Test([FromQuery] string text)
 {
     return(ModelConsumer.GetSentiment(text, SentimentList.Common));
 }