/// <summary> /// Trains a model and returns the associated <see cref="DisposableTrainedModel"/> instance, from which /// the model ID can be obtained. Upon disposal, the model will be deleted. /// </summary> /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the <link-to-label-tool-doc> to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param> /// <param name="useMultipageFiles">Whether or not to use multipage files for training.</param> /// <returns>A <see cref="DisposableTrainedModel"/> instance from which the trained model ID can be obtained.</returns> protected async Task <DisposableTrainedModel> CreateDisposableTrainedModelAsync(bool useTrainingLabels, bool useMultipageFiles = false) { var trainingClient = CreateFormTrainingClient(); var trainingFilesUri = new Uri(useMultipageFiles ? TestEnvironment.MultipageBlobContainerSasUrl : TestEnvironment.BlobContainerSasUrl); return(await DisposableTrainedModel.TrainModelAsync(trainingClient, trainingFilesUri, useTrainingLabels, PollingInterval)); }
/// <summary> /// Trains a model and returns the associated <see cref="DisposableTrainedModel"/> instance, from which /// the model ID can be obtained. Upon disposal, the model will be deleted. /// </summary> /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the <link-to-label-tool-doc> to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param> /// <returns>A <see cref="DisposableTrainedModel"/> instance from which the trained model ID can be obtained.</returns> protected async Task <DisposableTrainedModel> CreateDisposableTrainedModelAsync(bool useTrainingLabels) { var trainingClient = CreateInstrumentedFormTrainingClient(); var trainingFilesUri = new Uri(TestEnvironment.BlobContainerSasUrl); return(await DisposableTrainedModel.TrainModelAsync(trainingClient, trainingFilesUri, useTrainingLabels, PollingInterval)); }
/// <summary> /// Trains a model and returns the associated <see cref="DisposableTrainedModel"/> instance, from which /// the model ID can be obtained. Upon disposal, the model will be deleted. /// </summary> /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the <link-to-label-tool-doc> to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param> /// <returns>A <see cref="DisposableTrainedModel"/> instance from which the trained model ID can be obtained.</returns> protected async Task <DisposableTrainedModel> CreateDisposableTrainedModelAsync(bool useTrainingLabels) { var trainingClient = CreateInstrumentedFormTrainingClient(); var trainingFilesUri = new Uri(TestEnvironment.BlobContainerSasUrl); DisposableTrainedModel trainedModel; // TODO: sanitize body and enable body recording here. using (Recording.DisableRequestBodyRecording()) { trainedModel = await DisposableTrainedModel.TrainModelAsync(trainingClient, trainingFilesUri, useTrainingLabels); } return(trainedModel); }
/// <summary> /// Trains a model and returns the associated <see cref="DisposableTrainedModel"/> instance, from which /// the model ID can be obtained. Upon disposal, the model will be deleted. /// </summary> /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the <link-to-label-tool-doc> to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param> /// <param name="containerType">Type of container to use to execute training.</param> /// <param name="modelName">Optional model name.</param> /// <returns>A <see cref="DisposableTrainedModel"/> instance from which the trained model ID can be obtained.</returns> protected async Task <DisposableTrainedModel> CreateDisposableTrainedModelAsync(bool useTrainingLabels, ContainerType containerType = default, string modelName = default) { var trainingClient = CreateFormTrainingClient(); string trainingFiles = containerType switch { ContainerType.Singleforms => TestEnvironment.BlobContainerSasUrl, ContainerType.MultipageFiles => TestEnvironment.MultipageBlobContainerSasUrl, ContainerType.SelectionMarks => TestEnvironment.SelectionMarkBlobContainerSasUrl, _ => TestEnvironment.BlobContainerSasUrl, }; var trainingFilesUri = new Uri(trainingFiles); return(await DisposableTrainedModel.TrainModelAsync(trainingClient, trainingFilesUri, useTrainingLabels, modelName)); }