Search in sources :

Example 36 with GcsSource

use of com.google.cloud.datalabeling.v1beta1.GcsSource in project java-aiplatform by googleapis.

the class ImportDataTextEntityExtractionSample method importDataTextEntityExtractionSample.

static void importDataTextEntityExtractionSample(String project, String datasetId, String gcsSourceUri) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String location = "us-central1";
        String importSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "text_extraction_io_format_1.0.0.yaml";
        GcsSource.Builder gcsSource = GcsSource.newBuilder();
        gcsSource.addUris(gcsSourceUri);
        DatasetName datasetName = DatasetName.of(project, location, datasetId);
        List<ImportDataConfig> importDataConfigList = Collections.singletonList(ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri(importSchemaUri).build());
        OperationFuture<ImportDataResponse, ImportDataOperationMetadata> importDataResponseFuture = datasetServiceClient.importDataAsync(datasetName, importDataConfigList);
        System.out.format("Operation name: %s\n", importDataResponseFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        ImportDataResponse importDataResponse = importDataResponseFuture.get(300, TimeUnit.SECONDS);
        System.out.format("Import Data Text Entity Extraction Response: %s\n", importDataResponse.toString());
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Example 37 with GcsSource

use of com.google.cloud.datalabeling.v1beta1.GcsSource in project java-aiplatform by googleapis.

the class ImportDataVideoActionRecognitionSample method importDataVideoActionRecognitionSample.

static void importDataVideoActionRecognitionSample(String project, String datasetId, String gcsSourceUri) throws IOException, ExecutionException, InterruptedException {
    DatasetServiceSettings settings = DatasetServiceSettings.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 (DatasetServiceClient client = DatasetServiceClient.create(settings)) {
        GcsSource gcsSource = GcsSource.newBuilder().addUris(gcsSourceUri).build();
        ImportDataConfig importConfig0 = ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri("gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "video_action_recognition_io_format_1.0.0.yaml").build();
        List<ImportDataConfig> importConfigs = new ArrayList<>();
        importConfigs.add(importConfig0);
        DatasetName name = DatasetName.of(project, location, datasetId);
        OperationFuture<ImportDataResponse, ImportDataOperationMetadata> response = client.importDataAsync(name, importConfigs);
        // You can use OperationFuture.getInitialFuture to get a future representing the initial
        // response to the request, which contains information while the operation is in progress.
        System.out.format("Operation name: %s\n", response.getInitialFuture().get().getName());
        // OperationFuture.get() will block until the operation is finished.
        ImportDataResponse importDataResponse = response.get();
        System.out.format("importDataResponse: %s\n", importDataResponse);
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ArrayList(java.util.ArrayList) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Example 38 with GcsSource

use of com.google.cloud.datalabeling.v1beta1.GcsSource in project java-aiplatform by googleapis.

the class ImportDataVideoObjectTrackingSample method importDataVideObjectTracking.

static void importDataVideObjectTracking(String gcsSourceUri, String project, String datasetId) throws IOException, ExecutionException, InterruptedException, TimeoutException {
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String location = "us-central1";
        String importSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "video_object_tracking_io_format_1.0.0.yaml";
        GcsSource.Builder gcsSource = GcsSource.newBuilder();
        gcsSource.addUris(gcsSourceUri);
        DatasetName datasetName = DatasetName.of(project, location, datasetId);
        List<ImportDataConfig> importDataConfigs = Collections.singletonList(ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri(importSchemaUri).build());
        OperationFuture<ImportDataResponse, ImportDataOperationMetadata> importDataResponseFuture = datasetServiceClient.importDataAsync(datasetName, importDataConfigs);
        System.out.format("Operation name: %s\n", importDataResponseFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        ImportDataResponse importDataResponse = importDataResponseFuture.get(300, TimeUnit.SECONDS);
        System.out.format("Import Data Video Object Tracking Response: %s\n", importDataResponse.toString());
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Example 39 with GcsSource

use of com.google.cloud.datalabeling.v1beta1.GcsSource in project java-aiplatform by googleapis.

the class ImportDataImageClassificationSample method importDataImageClassificationSample.

static void importDataImageClassificationSample(String project, String datasetId, String gcsSourceUri) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String location = "us-central1";
        String importSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/ioformat/" + "image_classification_single_label_io_format_1.0.0.yaml";
        GcsSource.Builder gcsSource = GcsSource.newBuilder();
        gcsSource.addUris(gcsSourceUri);
        DatasetName datasetName = DatasetName.of(project, location, datasetId);
        List<ImportDataConfig> importDataConfigList = Collections.singletonList(ImportDataConfig.newBuilder().setGcsSource(gcsSource).setImportSchemaUri(importSchemaUri).build());
        OperationFuture<ImportDataResponse, ImportDataOperationMetadata> importDataResponseFuture = datasetServiceClient.importDataAsync(datasetName, importDataConfigList);
        System.out.format("Operation name: %s\n", importDataResponseFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        ImportDataResponse importDataResponse = importDataResponseFuture.get(300, TimeUnit.SECONDS);
        System.out.format("Import Data Image Classification Response: %s\n", importDataResponse.toString());
    }
}
Also used : ImportDataResponse(com.google.cloud.aiplatform.v1.ImportDataResponse) GcsSource(com.google.cloud.aiplatform.v1.GcsSource) ImportDataConfig(com.google.cloud.aiplatform.v1.ImportDataConfig) DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) ImportDataOperationMetadata(com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)

Example 40 with GcsSource

use of com.google.cloud.datalabeling.v1beta1.GcsSource in project java-aiplatform by googleapis.

the class CreateBatchPredictionJobSample method createBatchPredictionJobSample.

static void createBatchPredictionJobSample(String project, String displayName, String model, String instancesFormat, String gcsSourceUri, String predictionsFormat, 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)) {
        // Passing in an empty Value object for model parameters
        Value modelParameters = ValueConverter.EMPTY_VALUE;
        GcsSource gcsSource = GcsSource.newBuilder().addUris(gcsSourceUri).build();
        BatchPredictionJob.InputConfig inputConfig = BatchPredictionJob.InputConfig.newBuilder().setInstancesFormat(instancesFormat).setGcsSource(gcsSource).build();
        GcsDestination gcsDestination = GcsDestination.newBuilder().setOutputUriPrefix(gcsDestinationOutputUriPrefix).build();
        BatchPredictionJob.OutputConfig outputConfig = BatchPredictionJob.OutputConfig.newBuilder().setPredictionsFormat(predictionsFormat).setGcsDestination(gcsDestination).build();
        MachineSpec machineSpec = MachineSpec.newBuilder().setMachineType("n1-standard-2").setAcceleratorType(AcceleratorType.NVIDIA_TESLA_K80).setAcceleratorCount(1).build();
        BatchDedicatedResources dedicatedResources = BatchDedicatedResources.newBuilder().setMachineSpec(machineSpec).setStartingReplicaCount(1).setMaxReplicaCount(1).build();
        String modelName = ModelName.of(project, location, model).toString();
        BatchPredictionJob batchPredictionJob = BatchPredictionJob.newBuilder().setDisplayName(displayName).setModel(modelName).setModelParameters(modelParameters).setInputConfig(inputConfig).setOutputConfig(outputConfig).setDedicatedResources(dedicatedResources).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) BatchDedicatedResources(com.google.cloud.aiplatform.v1.BatchDedicatedResources) 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) MachineSpec(com.google.cloud.aiplatform.v1.MachineSpec) GcsDestination(com.google.cloud.aiplatform.v1.GcsDestination) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Aggregations

GcsSource (com.google.cloud.aiplatform.v1.GcsSource)16 BatchPredictionJob (com.google.cloud.aiplatform.v1.BatchPredictionJob)8 DatasetName (com.google.cloud.aiplatform.v1.DatasetName)8 DatasetServiceClient (com.google.cloud.aiplatform.v1.DatasetServiceClient)8 DatasetServiceSettings (com.google.cloud.aiplatform.v1.DatasetServiceSettings)8 GcsDestination (com.google.cloud.aiplatform.v1.GcsDestination)8 ImportDataConfig (com.google.cloud.aiplatform.v1.ImportDataConfig)8 ImportDataOperationMetadata (com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)8 ImportDataResponse (com.google.cloud.aiplatform.v1.ImportDataResponse)8 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)8 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)8 LocationName (com.google.cloud.aiplatform.v1.LocationName)7 Document (com.google.cloud.documentai.v1beta2.Document)5 DocumentUnderstandingServiceClient (com.google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient)5 GcsSource (com.google.cloud.documentai.v1beta2.GcsSource)5 InputConfig (com.google.cloud.documentai.v1beta2.InputConfig)5 ProcessDocumentRequest (com.google.cloud.documentai.v1beta2.ProcessDocumentRequest)5 GcsSource (com.google.cloud.translate.v3.GcsSource)5 LocationName (com.google.cloud.translate.v3.LocationName)5 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)5