use of com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputConfig in project java-aiplatform by googleapis.
the class CreateBatchPredictionJobTextEntityExtractionSample method createBatchPredictionJobTextEntityExtractionSample.
static void createBatchPredictionJobTextEntityExtractionSample(String project, String location, String displayName, String modelId, String gcsSourceUri, String gcsDestinationOutputUriPrefix) throws IOException {
// The AI Platform services require regional API endpoints.
JobServiceSettings settings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
// the "close" method on the client to safely clean up any remaining background resources.
try (JobServiceClient client = JobServiceClient.create(settings)) {
try {
String modelName = ModelName.of(project, location, modelId).toString();
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();
BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().setDisplayName(displayName).setModel(modelName).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());
} catch (ApiException ex) {
System.out.format("Exception: %s\n", ex.getLocalizedMessage());
}
}
}
use of com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputConfig 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());
}
}
Aggregations