예제 #1
0
        public async Task <IActionResult> ClassifyBase64(string base64image)
        {
            if (!ModelState.IsValid || base64image == null)
            {
                return(BadRequest("Bad request because of invalid model state or null parameter"));
            }
            byte[] imageData = await ImageTransformer.Base64ToByteArray(base64image);

            if (imageData == null)
            {
                return(BadRequest("Bad request because of an invalid base64 image"));
            }
            return(Classify(imageData));
        }
        public async Task <IActionResult> SaveUserBase64Contribution(string base64image, string predictedLabel)
        {
            if (!ModelState.IsValid || base64image == null)
            {
                return(BadRequest("Bad request because of invalid model state or null parameter"));
            }
            byte[] imageData = await ImageTransformer.Base64ToByteArray(base64image);

            if (imageData == null)
            {
                return(BadRequest("Bad request because of an invalid base64 image"));
            }
            string filename = await Transformer.SaveBytesToFile(imageData);

            if (filename == null)
            {
                return(BadRequest("The file which you uploaded can't save in server"));
            }
            Sentiment user = new Sentiment(filename, predictedLabel, DateTime.Now);

            sentimentService.Insert(user);
            return(Ok(user));
        }