Search in sources :

Example 11 with BatchPredictionJob

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

the class CreateBatchPredictionJobVideoActionRecognitionSample method createBatchPredictionJobVideoActionRecognitionSample.

static void createBatchPredictionJobVideoActionRecognitionSample(String project, String displayName, String model, String gcsSourceUri, String gcsDestinationOutputUriPrefix) throws IOException {
    JobServiceSettings settings = JobServiceSettings.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 (JobServiceClient client = JobServiceClient.create(settings)) {
        Value modelParameters = ValueConverter.EMPTY_VALUE;
        GcsSource gcsSource = GcsSource.newBuilder().addUris(gcsSourceUri).build();
        BatchPredictionJob.InputConfig inputConfig = BatchPredictionJob.InputConfig.newBuilder().setInstancesFormat("jsonl").setGcsSource(gcsSource).build();
        GcsDestination gcsDestination = GcsDestination.newBuilder().setOutputUriPrefix(gcsDestinationOutputUriPrefix).build();
        BatchPredictionJob.OutputConfig outputConfig = BatchPredictionJob.OutputConfig.newBuilder().setPredictionsFormat("jsonl").setGcsDestination(gcsDestination).build();
        String modelName = ModelName.of(project, location, model).toString();
        BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().setDisplayName(displayName).setModel(modelName).setModelParameters(modelParameters).setInputConfig(inputConfig).setOutputConfig(outputConfig).build();
        LocationName parent = LocationName.of(project, location);
        BatchPredictionJob response = client.createBatchPredictionJob(parent, batchPredictionJob);
        System.out.format("response: %s\n", response);
        System.out.format("\tName: %s\n", response.getName());
    }
}
Also used : JobServiceSettings(com.google.cloud.aiplatform.v1.JobServiceSettings) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) BatchPredictionJob(com.google.cloud.aiplatform.v1.BatchPredictionJob) Value(com.google.protobuf.Value) JobServiceClient(com.google.cloud.aiplatform.v1.JobServiceClient) GcsDestination(com.google.cloud.aiplatform.v1.GcsDestination) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Aggregations

BatchPredictionJob (com.google.cloud.aiplatform.v1.BatchPredictionJob)9 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)9 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)9 GcsDestination (com.google.cloud.aiplatform.v1.GcsDestination)8 GcsSource (com.google.cloud.aiplatform.v1.GcsSource)8 LocationName (com.google.cloud.aiplatform.v1.LocationName)8 Value (com.google.protobuf.Value)5 BigQueryDestination (com.google.cloud.aiplatform.v1.BigQueryDestination)4 BigQuerySource (com.google.cloud.aiplatform.v1.BigQuerySource)4 ApiException (com.google.api.gax.rpc.ApiException)3 BatchDedicatedResources (com.google.cloud.aiplatform.v1.BatchDedicatedResources)3 InputConfig (com.google.cloud.aiplatform.v1.BatchPredictionJob.InputConfig)3 OutputConfig (com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputConfig)3 OutputInfo (com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputInfo)3 CompletionStats (com.google.cloud.aiplatform.v1.CompletionStats)3 MachineSpec (com.google.cloud.aiplatform.v1.MachineSpec)3 ResourcesConsumed (com.google.cloud.aiplatform.v1.ResourcesConsumed)3 Any (com.google.protobuf.Any)3 Status (com.google.rpc.Status)3 ListBatchPredictionJobsPagedResponse (com.google.cloud.aiplatform.v1.JobServiceClient.ListBatchPredictionJobsPagedResponse)2