コード例 #1
0
        public virtual async Task <TrainingOperation> StartTrainingAsync(Uri trainingFilesUri, bool useTrainingLabels, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

            var trainRequest = new TrainRequest_internal(trainingFilesUri.AbsoluteUri, trainingFileFilter, useTrainingLabels);

            ResponseWithHeaders <ServiceTrainCustomModelAsyncHeaders> response = await ServiceClient.TrainCustomModelAsyncAsync(trainRequest).ConfigureAwait(false);

            return(new TrainingOperation(response.Headers.Location, ServiceClient, Diagnostics));
        }
コード例 #2
0
        public virtual TrainingOperation StartTraining(Uri trainingFilesUri, bool useTrainingLabels = false, TrainingFileFilter filter = default, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

            var trainRequest = new TrainRequest_internal(trainingFilesUri.AbsoluteUri, filter, useTrainingLabels);

            ResponseWithHeaders <ServiceTrainCustomModelAsyncHeaders> response = ServiceClient.TrainCustomModelAsync(trainRequest);

            return(new TrainingOperation(response.Headers.Location, ServiceClient));
        }
コード例 #3
0
        /// <summary>
        /// Trains a model from a collection of custom forms in a blob storage container.
        /// </summary>
        /// <param name="trainingFilesUri">An externally accessible Azure storage blob container Uri.
        /// For more information see <a href="https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set#upload-your-training-data"/>.</param>
        /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the &lt;link-to-label-tool-doc&gt; to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param>
        /// <param name="trainingFileFilter">Filter to apply to the documents in the source path for training.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <returns>
        /// <para>A <see cref="TrainingOperation"/> to wait on this long-running operation. Its <see cref="TrainingOperation.Value"/> upon successful
        /// completion will contain meta-data about the trained model.</para>
        /// <para>Even if training fails, a model is created in the Form Recognizer account with an "invalid" status.
        /// A <see cref="RequestFailedException"/> will be raised containing the modelId to access this invalid model.</para>
        /// </returns>
        public virtual async Task <TrainingOperation> StartTrainingAsync(Uri trainingFilesUri, bool useTrainingLabels, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

            using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormTrainingClient)}.{nameof(StartTraining)}");
            scope.Start();

            try
            {
                var trainRequest = new TrainRequest(trainingFilesUri.AbsoluteUri)
                {
                    SourceFilter = trainingFileFilter, UseLabelFile = useTrainingLabels
                };

                ResponseWithHeaders <ServiceTrainCustomModelAsyncHeaders> response = await ServiceClient.TrainCustomModelAsyncAsync(trainRequest).ConfigureAwait(false);

                return(new TrainingOperation(response.Headers.Location, ServiceClient, Diagnostics));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #4
0
        public virtual async Task <TrainingOperation> StartTrainingAsync(Uri trainingFiles, bool useLabels = false, TrainingFileFilter filter = default, CancellationToken cancellationToken = default)
        {
            var trainRequest = new TrainRequest_internal(trainingFiles.AbsoluteUri, filter, useLabels);

            ResponseWithHeaders <ServiceTrainCustomModelAsyncHeaders> response = await ServiceClient.RestClient.TrainCustomModelAsyncAsync(trainRequest).ConfigureAwait(false);

            return(new TrainingOperation(response.Headers.Location, ServiceClient));
        }
コード例 #5
0
        public virtual async Task <TrainingOperation> StartTrainingAsync(Uri trainingFiles, bool useLabels = false, TrainingFileFilter filter = default, CancellationToken cancellationToken = default)
        {
            await Task.Run(() => { }).ConfigureAwait(false);

            throw new NotImplementedException();

            //TrainRequest_internal trainRequest = new TrainRequest_internal() { Source = trainingFiles.AbsoluteUri };

            //// TODO: Q1 - if there's a way to default a property value, set filter.Path ="" and set it here in a nicer way.
            //// https://github.com/Azure/azure-sdk-for-net/issues/10359
            //if (filter != default)
            //{
            //    trainRequest.SourceFilter = filter;
            //}

            //ResponseWithHeaders<TrainCustomModelAsyncHeaders> response = await ServiceClient.RestClient.TrainCustomModelAsyncAsync(trainRequest).ConfigureAwait(false);
            //return new TrainingOperation(ServiceClient, response.Headers.Location);
        }
コード例 #6
0
        public virtual TrainingOperation StartTraining(Uri trainingFiles, bool useLabels = false, TrainingFileFilter filter = default, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();

            //TrainRequest_internal trainRequest = new TrainRequest_internal() { Source = trainingFiles.AbsoluteUri };

            //// TODO: Q1 - if there's a way to default a property value, set filter.Path ="" and set it here in a nicer way.
            //// https://github.com/Azure/autorest.csharp/issues/467
            //// When this is complete, we will be able to default filter.Path to "".
            //// Decision to make, do we always send filter, or only if needed?
            //// Tracking with https://github.com/Azure/azure-sdk-for-net/issues/10359
            //if (filter != default)
            //{
            //    trainRequest.SourceFilter = filter;
            //}

            //ResponseWithHeaders<TrainCustomModelAsyncHeaders> response = ServiceClient.RestClient.TrainCustomModelAsync(trainRequest);
            //return new TrainingOperation(ServiceClient, response.Headers.Location);
        }