public IEnumerable <Label> GetBoundingBoxes(Topic topic, string imageId)
        {
            #region validation

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (string.IsNullOrEmpty(imageId))
            {
                throw new ArgumentNullException(nameof(imageId));
            }

            #endregion

            var modelId = LoadModel();

            MultipartFormDataContent multipartFormDataContent = new MultipartFormDataContent();
            using (Stream imageFileStream = ImageFileRepository.GetImageFile(topic, imageId))
            {
                multipartFormDataContent.AddFileAsByteContent(imageFileStream, "image", imageId);
            }
            multipartFormDataContent.Add(new StringContent(modelId), "model");

            HttpClient httpClient = HttpClientFactory.GetInferenceContainerHttpClient();

            Uri uri = UriUtil.GetUri(httpClient.BaseAddress, "detect");

            using MemoryStream memoryStream = new MemoryStream(httpClient.PostReadByteArray(uri, multipartFormDataContent));
            using StreamReader streamReader = new StreamReader(memoryStream);
            return(ParseLabelResult(streamReader.ReadToEnd()));
        }
Exemple #2
0
        public Stream GetImage(Topic topic, string imageFileName)
        {
            #region validation

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (string.IsNullOrEmpty(imageFileName))
            {
                throw new ArgumentNullException(nameof(imageFileName));
            }

            #endregion

            return(ImageFileRepository.GetImageFile(topic, imageFileName));
        }