Search in sources :

Example 6 with InputDataConfig

use of com.google.cloud.aiplatform.v1.InputDataConfig in project java-aiplatform by googleapis.

the class CreateTrainingPipelineTextSentimentAnalysisSample method createTrainingPipelineTextSentimentAnalysisSample.

static void createTrainingPipelineTextSentimentAnalysisSample(String project, String trainingPipelineDisplayName, String datasetId, String modelDisplayName) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        String trainingTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/" + "automl_text_sentiment_1.0.0.yaml";
        LocationName locationName = LocationName.of(project, location);
        AutoMlTextSentimentInputs trainingTaskInputs = AutoMlTextSentimentInputs.newBuilder().setSentimentMax(4).build();
        InputDataConfig trainingInputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).build();
        Model model = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(trainingPipelineDisplayName).setTrainingTaskDefinition(trainingTaskDefinition).setTrainingTaskInputs(ValueConverter.toValue(trainingTaskInputs)).setInputDataConfig(trainingInputDataConfig).setModelToUpload(model).build();
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.createTrainingPipeline(locationName, trainingPipeline);
        System.out.println("Create Training Pipeline Text Sentiment Analysis Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("State: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStartTime %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfig = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s", inputDataConfig.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfig.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfig.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfig.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Filter: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Filter: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Filter: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfig.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfig.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\tModel To Upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLabels: %sn\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\t\tPredict Schemata");
        System.out.format("\t\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\t\tSupported Export Format");
            System.out.format("\t\t\tId: %s\n", exportFormat.getId());
        }
        ModelContainerSpec modelContainerSpec = modelResponse.getContainerSpec();
        System.out.println("\t\tContainer Spec");
        System.out.format("\t\t\tImage Uri: %s\n", modelContainerSpec.getImageUri());
        System.out.format("\t\t\tCommand: %s\n", modelContainerSpec.getCommandList());
        System.out.format("\t\t\tArgs: %s\n", modelContainerSpec.getArgsList());
        System.out.format("\t\t\tPredict Route: %s\n", modelContainerSpec.getPredictRoute());
        System.out.format("\t\t\tHealth Route: %s\n", modelContainerSpec.getHealthRoute());
        for (EnvVar envVar : modelContainerSpec.getEnvList()) {
            System.out.println("\t\t\tEnv");
            System.out.format("\t\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : modelContainerSpec.getPortsList()) {
            System.out.println("\t\t\tPort");
            System.out.format("\t\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\t\tDeployed Model");
            System.out.format("\t\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) AutoMlTextSentimentInputs(com.google.cloud.aiplatform.v1.schema.trainingjob.definition.AutoMlTextSentimentInputs) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Example 7 with InputDataConfig

use of com.google.cloud.aiplatform.v1.InputDataConfig in project java-aiplatform by googleapis.

the class CreateTrainingPipelineVideoActionRecognitionSample method createTrainingPipelineVideoActionRecognitionSample.

static void createTrainingPipelineVideoActionRecognitionSample(String project, String displayName, String datasetId, String modelDisplayName) throws IOException {
    PipelineServiceSettings settings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    String location = "us-central1";
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient client = PipelineServiceClient.create(settings)) {
        AutoMlVideoActionRecognitionInputs trainingTaskInputs = AutoMlVideoActionRecognitionInputs.newBuilder().setModelType(ModelType.CLOUD).build();
        InputDataConfig inputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).build();
        Model modelToUpload = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(displayName).setTrainingTaskDefinition("gs://google-cloud-aiplatform/schema/trainingjob/definition/" + "automl_video_action_recognition_1.0.0.yaml").setTrainingTaskInputs(ValueConverter.toValue(trainingTaskInputs)).setInputDataConfig(inputDataConfig).setModelToUpload(modelToUpload).build();
        LocationName parent = LocationName.of(project, location);
        TrainingPipeline response = client.createTrainingPipeline(parent, trainingPipeline);
        System.out.format("response: %s\n", response);
        System.out.format("Name: %s\n", response.getName());
    }
}
Also used : TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient) AutoMlVideoActionRecognitionInputs(com.google.cloud.aiplatform.v1.schema.trainingjob.definition.AutoMlVideoActionRecognitionInputs) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Example 8 with InputDataConfig

use of com.google.cloud.aiplatform.v1.InputDataConfig in project java-aiplatform by googleapis.

the class CreateTrainingPipelineTextClassificationSample method createTrainingPipelineTextClassificationSample.

static void createTrainingPipelineTextClassificationSample(String project, String trainingPipelineDisplayName, String datasetId, String modelDisplayName) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        String trainingTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/" + "automl_text_classification_1.0.0.yaml";
        LocationName locationName = LocationName.of(project, location);
        AutoMlTextClassificationInputs trainingTaskInputs = AutoMlTextClassificationInputs.newBuilder().setMultiLabel(false).build();
        InputDataConfig trainingInputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).build();
        Model model = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(trainingPipelineDisplayName).setTrainingTaskDefinition(trainingTaskDefinition).setTrainingTaskInputs(ValueConverter.toValue(trainingTaskInputs)).setInputDataConfig(trainingInputDataConfig).setModelToUpload(model).build();
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.createTrainingPipeline(locationName, trainingPipeline);
        System.out.println("Create Training Pipeline Text Classification Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("State: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStartTime %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfig = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s", inputDataConfig.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfig.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfig.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfig.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Filter: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Filter: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Filter: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfig.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfig.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\tModel To Upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLabels: %sn\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\t\tPredict Schemata");
        System.out.format("\t\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\t\tSupported Export Format");
            System.out.format("\t\t\tId: %s\n", exportFormat.getId());
        }
        ModelContainerSpec modelContainerSpec = modelResponse.getContainerSpec();
        System.out.println("\t\tContainer Spec");
        System.out.format("\t\t\tImage Uri: %s\n", modelContainerSpec.getImageUri());
        System.out.format("\t\t\tCommand: %s\n", modelContainerSpec.getCommandList());
        System.out.format("\t\t\tArgs: %s\n", modelContainerSpec.getArgsList());
        System.out.format("\t\t\tPredict Route: %s\n", modelContainerSpec.getPredictRoute());
        System.out.format("\t\t\tHealth Route: %s\n", modelContainerSpec.getHealthRoute());
        for (EnvVar envVar : modelContainerSpec.getEnvList()) {
            System.out.println("\t\t\tEnv");
            System.out.format("\t\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : modelContainerSpec.getPortsList()) {
            System.out.println("\t\t\tPort");
            System.out.format("\t\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\t\tDeployed Model");
            System.out.format("\t\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient) AutoMlTextClassificationInputs(com.google.cloud.aiplatform.v1beta1.schema.trainingjob.definition.AutoMlTextClassificationInputs)

Example 9 with InputDataConfig

use of com.google.cloud.aiplatform.v1.InputDataConfig in project java-aiplatform by googleapis.

the class CreateTrainingPipelineTextEntityExtractionSample method createTrainingPipelineTextEntityExtractionSample.

static void createTrainingPipelineTextEntityExtractionSample(String project, String trainingPipelineDisplayName, String datasetId, String modelDisplayName) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        String trainingTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/" + "automl_text_extraction_1.0.0.yaml";
        LocationName locationName = LocationName.of(project, location);
        InputDataConfig trainingInputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).build();
        Model model = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(trainingPipelineDisplayName).setTrainingTaskDefinition(trainingTaskDefinition).setTrainingTaskInputs(ValueConverter.EMPTY_VALUE).setInputDataConfig(trainingInputDataConfig).setModelToUpload(model).build();
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.createTrainingPipeline(locationName, trainingPipeline);
        System.out.println("Create Training Pipeline Text Entity Extraction Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("State: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStartTime %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfig = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s", inputDataConfig.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfig.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfig.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfig.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Filter: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Filter: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Filter: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfig.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfig.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\tModel To Upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLabels: %sn\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\t\tPredict Schemata");
        System.out.format("\t\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\t\tSupported Export Format");
            System.out.format("\t\t\tId: %s\n", exportFormat.getId());
        }
        ModelContainerSpec modelContainerSpec = modelResponse.getContainerSpec();
        System.out.println("\t\tContainer Spec");
        System.out.format("\t\t\tImage Uri: %s\n", modelContainerSpec.getImageUri());
        System.out.format("\t\t\tCommand: %s\n", modelContainerSpec.getCommandList());
        System.out.format("\t\t\tArgs: %s\n", modelContainerSpec.getArgsList());
        System.out.format("\t\t\tPredict Route: %s\n", modelContainerSpec.getPredictRoute());
        System.out.format("\t\t\tHealth Route: %s\n", modelContainerSpec.getHealthRoute());
        for (EnvVar envVar : modelContainerSpec.getEnvList()) {
            System.out.println("\t\t\tEnv");
            System.out.format("\t\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : modelContainerSpec.getPortsList()) {
            System.out.println("\t\t\tPort");
            System.out.format("\t\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\t\tDeployed Model");
            System.out.format("\t\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Example 10 with InputDataConfig

use of com.google.cloud.aiplatform.v1.InputDataConfig in project java-aiplatform by googleapis.

the class CreateTrainingPipelineVideoClassificationSample method createTrainingPipelineVideoClassification.

static void createTrainingPipelineVideoClassification(String videoClassificationDisplayName, String datasetId, String modelDisplayName, String project) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        LocationName locationName = LocationName.of(project, location);
        String trainingTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/" + "automl_video_classification_1.0.0.yaml";
        InputDataConfig inputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).build();
        Model model = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(videoClassificationDisplayName).setTrainingTaskDefinition(trainingTaskDefinition).setTrainingTaskInputs(ValueConverter.EMPTY_VALUE).setInputDataConfig(inputDataConfig).setModelToUpload(model).build();
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.createTrainingPipeline(locationName, trainingPipeline);
        System.out.println("Create Training Pipeline Video Classification Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition: %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("\tState: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStart Time: %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfigResponse = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s\n", inputDataConfigResponse.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfigResponse.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfigResponse.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfigResponse.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Fraction: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Fraction: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfigResponse.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfigResponse.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\tModel To Upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMeta Data: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList().toString());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList().toString());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList().toString());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLables: %s\n", modelResponse.getLabelsMap());
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit)

Aggregations

InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)13 Model (com.google.cloud.aiplatform.v1.Model)13 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)13 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)13 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)13 LocationName (com.google.cloud.aiplatform.v1.LocationName)12 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)11 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)11 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)11 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)11 Status (com.google.rpc.Status)11 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)10 DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)9 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)9 Port (com.google.cloud.aiplatform.v1.Port)9 PredictSchemata (com.google.cloud.aiplatform.v1.PredictSchemata)9 ExportFormat (com.google.cloud.aiplatform.v1.Model.ExportFormat)6 Value (com.google.protobuf.Value)2 ArrayList (java.util.ArrayList)2 GcsDestination (com.google.cloud.aiplatform.v1.GcsDestination)1