public async Task <ActionResult <CustomVisionViewModel> > CustomVision([FromForm] CustomVisionRequest request) { var errorContent = ""; if (string.IsNullOrWhiteSpace(request.CustomVisionPredictionKey)) { errorContent += $"Missing or invalid Custom Vision Prediction Key (see 'Azure Settings' tab){Environment.NewLine}"; } if (string.IsNullOrWhiteSpace(request.CustomVisionEndpoint)) { errorContent += $"Missing or invalid Custom Vision Prediction Endpoint (see 'Azure Settings' tab){Environment.NewLine}"; } if (string.IsNullOrWhiteSpace(request.ImageUrl) && (request.File == null || !_allowedFileContentType.Contains(request.File.ContentType))) { errorContent += $"Missing or invalid ImageUrl / no file provided{Environment.NewLine}"; } if (request.ProjectId == null || Guid.Empty.Equals(request.ProjectId)) { errorContent += $"Missing or invalid Project Id{Environment.NewLine}"; } if (string.IsNullOrWhiteSpace(request.IterationPublishedName)) { errorContent += $"Missing or invalid Iteration Published Name{Environment.NewLine}"; } if (!string.IsNullOrWhiteSpace(errorContent)) { return(View(CustomVisionViewModel.Analyzed(request, new CustomVisionResponse { OtherErrorMessage = "Request not processed due to the following error(s):", OtherErrorContent = errorContent }))); } Track("Vision_CustomVision"); var imageAnalyzer = new ImageCustomVisionAnalyzer(request.CustomVisionPredictionKey, request.CustomVisionEndpoint, _httpClientFactory); var analyzeResult = await imageAnalyzer.AnalyzeAsync(request.ImageUrl, request.File, request.ProjectId, request.IterationPublishedName, request.ProjectType); return(View(CustomVisionViewModel.Analyzed(request, analyzeResult))); }
public IActionResult CustomVision() { return(View(CustomVisionViewModel.NotAnalyzed())); }