use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.
the class ImportDataTextClassificationSingleLabelSample method importDataTextClassificationSingleLabelSample.
static void importDataTextClassificationSingleLabelSample(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_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 Text Classification Response: %s\n", importDataResponse.toString());
}
}
use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.
the class ImportDataTextSentimentAnalysisSample method importDataTextSentimentAnalysisSample.
static void importDataTextSentimentAnalysisSample(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_sentiment_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 Sentiment Analysis Response: %s\n", importDataResponse.toString());
}
}
use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.
the class ImportDataVideoClassificationSample method importDataVideoClassification.
static void importDataVideoClassification(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_classification_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(1800, TimeUnit.SECONDS);
System.out.format("Import Data Video Classification Response: %s\n", importDataResponse.toString());
}
}
use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.
the class CreateDataLabelingJobImageSample method createDataLabelingJobImage.
static void createDataLabelingJobImage(String project, String displayName, String datasetId, String instructionUri, String annotationSpec) throws IOException {
JobServiceSettings jobServiceSettings = 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 jobServiceClient = JobServiceClient.create(jobServiceSettings)) {
String location = "us-central1";
LocationName locationName = LocationName.of(project, location);
String jsonString = "{\"annotation_specs\": [ " + annotationSpec + "]}";
Value.Builder annotationSpecValue = Value.newBuilder();
JsonFormat.parser().merge(jsonString, annotationSpecValue);
DatasetName datasetName = DatasetName.of(project, location, datasetId);
DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().setDisplayName(displayName).setLabelerCount(1).setInstructionUri(instructionUri).setInputsSchemaUri("gs://google-cloud-aiplatform/schema/datalabelingjob/inputs/" + "image_classification.yaml").addDatasets(datasetName.toString()).setInputs(annotationSpecValue).putAnnotationLabels("aiplatform.googleapis.com/annotation_set_name", "my_test_saved_query").build();
DataLabelingJob dataLabelingJobResponse = jobServiceClient.createDataLabelingJob(locationName, dataLabelingJob);
System.out.println("Create Data Labeling Job Image Response");
System.out.format("\tName: %s\n", dataLabelingJobResponse.getName());
System.out.format("\tDisplay Name: %s\n", dataLabelingJobResponse.getDisplayName());
System.out.format("\tDatasets: %s\n", dataLabelingJobResponse.getDatasetsList());
System.out.format("\tLabeler Count: %s\n", dataLabelingJobResponse.getLabelerCount());
System.out.format("\tInstruction Uri: %s\n", dataLabelingJobResponse.getInstructionUri());
System.out.format("\tInputs Schema Uri: %s\n", dataLabelingJobResponse.getInputsSchemaUri());
System.out.format("\tInputs: %s\n", dataLabelingJobResponse.getInputs());
System.out.format("\tState: %s\n", dataLabelingJobResponse.getState());
System.out.format("\tLabeling Progress: %s\n", dataLabelingJobResponse.getLabelingProgress());
System.out.format("\tCreate Time: %s\n", dataLabelingJobResponse.getCreateTime());
System.out.format("\tUpdate Time: %s\n", dataLabelingJobResponse.getUpdateTime());
System.out.format("\tLabels: %s\n", dataLabelingJobResponse.getLabelsMap());
System.out.format("\tSpecialist Pools: %s\n", dataLabelingJobResponse.getSpecialistPoolsList());
for (Map.Entry<String, String> annotationLabelMap : dataLabelingJobResponse.getAnnotationLabelsMap().entrySet()) {
System.out.println("\tAnnotation Level");
System.out.format("\t\tkey: %s\n", annotationLabelMap.getKey());
System.out.format("\t\tvalue: %s\n", annotationLabelMap.getValue());
}
Money money = dataLabelingJobResponse.getCurrentSpend();
System.out.println("\tCurrent Spend");
System.out.format("\t\tCurrency Code: %s\n", money.getCurrencyCode());
System.out.format("\t\tUnits: %s\n", money.getUnits());
System.out.format("\t\tNanos: %s\n", money.getNanos());
}
}
use of com.google.cloud.aiplatform.v1beta1.DatasetName in project java-aiplatform by googleapis.
the class CreateDataLabelingJobSample method createDataLabelingJob.
static void createDataLabelingJob(String project, String displayName, String datasetId, String instructionUri, String inputsSchemaUri, String annotationSpec) throws IOException {
JobServiceSettings jobServiceSettings = 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 jobServiceClient = JobServiceClient.create(jobServiceSettings)) {
String location = "us-central1";
LocationName locationName = LocationName.of(project, location);
String jsonString = "{\"annotation_specs\": [ " + annotationSpec + "]}";
Value.Builder annotationSpecValue = Value.newBuilder();
JsonFormat.parser().merge(jsonString, annotationSpecValue);
DatasetName datasetName = DatasetName.of(project, location, datasetId);
DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().setDisplayName(displayName).setLabelerCount(1).setInstructionUri(instructionUri).setInputsSchemaUri(inputsSchemaUri).addDatasets(datasetName.toString()).setInputs(annotationSpecValue).putAnnotationLabels("aiplatform.googleapis.com/annotation_set_name", "my_test_saved_query").build();
DataLabelingJob dataLabelingJobResponse = jobServiceClient.createDataLabelingJob(locationName, dataLabelingJob);
System.out.println("Create Data Labeling Job Response");
System.out.format("\tName: %s\n", dataLabelingJobResponse.getName());
System.out.format("\tDisplay Name: %s\n", dataLabelingJobResponse.getDisplayName());
System.out.format("\tDatasets: %s\n", dataLabelingJobResponse.getDatasetsList());
System.out.format("\tLabeler Count: %s\n", dataLabelingJobResponse.getLabelerCount());
System.out.format("\tInstruction Uri: %s\n", dataLabelingJobResponse.getInstructionUri());
System.out.format("\tInputs Schema Uri: %s\n", dataLabelingJobResponse.getInputsSchemaUri());
System.out.format("\tInputs: %s\n", dataLabelingJobResponse.getInputs());
System.out.format("\tState: %s\n", dataLabelingJobResponse.getState());
System.out.format("\tLabeling Progress: %s\n", dataLabelingJobResponse.getLabelingProgress());
System.out.format("\tCreate Time: %s\n", dataLabelingJobResponse.getCreateTime());
System.out.format("\tUpdate Time: %s\n", dataLabelingJobResponse.getUpdateTime());
System.out.format("\tLabels: %s\n", dataLabelingJobResponse.getLabelsMap());
System.out.format("\tSpecialist Pools: %s\n", dataLabelingJobResponse.getSpecialistPoolsList());
for (Map.Entry<String, String> annotationLabelMap : dataLabelingJobResponse.getAnnotationLabelsMap().entrySet()) {
System.out.println("\tAnnotation Level");
System.out.format("\t\tkey: %s\n", annotationLabelMap.getKey());
System.out.format("\t\tvalue: %s\n", annotationLabelMap.getValue());
}
Money money = dataLabelingJobResponse.getCurrentSpend();
System.out.println("\tCurrent Spend");
System.out.format("\t\tCurrency Code: %s\n", money.getCurrencyCode());
System.out.format("\t\tUnits: %s\n", money.getUnits());
System.out.format("\t\tNanos: %s\n", money.getNanos());
}
}
Aggregations