use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class CreateDataLabelingJobSpecialistPoolSample method createDataLabelingJobSpecialistPoolSample.
static void createDataLabelingJobSpecialistPoolSample(String project, String displayName, String dataset, String specialistPool, String instructionUri, String inputsSchemaUri, String annotationSpec) 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)) {
JsonArray jsonAnnotationSpecs = new JsonArray();
jsonAnnotationSpecs.add(annotationSpec);
JsonObject jsonInputs = new JsonObject();
jsonInputs.add("annotation_specs", jsonAnnotationSpecs);
Value.Builder inputsBuilder = Value.newBuilder();
JsonFormat.parser().merge(jsonInputs.toString(), inputsBuilder);
Value inputs = inputsBuilder.build();
String datasetName = DatasetName.of(project, location, dataset).toString();
String specialistPoolName = SpecialistPoolName.of(project, location, specialistPool).toString();
DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().setDisplayName(displayName).addDatasets(datasetName).setLabelerCount(1).setInstructionUri(instructionUri).setInputsSchemaUri(inputsSchemaUri).setInputs(inputs).putAnnotationLabels("aiplatform.googleapis.com/annotation_set_name", "data_labeling_job_specialist_pool").addSpecialistPools(specialistPoolName).build();
LocationName parent = LocationName.of(project, location);
DataLabelingJob response = client.createDataLabelingJob(parent, dataLabelingJob);
System.out.format("response: %s\n", response);
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class CreateDatasetImageSample method createDatasetImageSample.
static void createDatasetImageSample(String project, String datasetDisplayName) 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 metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml";
LocationName locationName = LocationName.of(project, location);
Dataset dataset = Dataset.newBuilder().setDisplayName(datasetDisplayName).setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
System.out.format("Operation name: %s\n", datasetFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
Dataset datasetResponse = datasetFuture.get(120, TimeUnit.SECONDS);
System.out.println("Create Image Dataset Response");
System.out.format("Name: %s\n", datasetResponse.getName());
System.out.format("Display Name: %s\n", datasetResponse.getDisplayName());
System.out.format("Metadata Schema Uri: %s\n", datasetResponse.getMetadataSchemaUri());
System.out.format("Metadata: %s\n", datasetResponse.getMetadata());
System.out.format("Create Time: %s\n", datasetResponse.getCreateTime());
System.out.format("Update Time: %s\n", datasetResponse.getUpdateTime());
System.out.format("Labels: %s\n", datasetResponse.getLabelsMap());
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class CreateDatasetSample method createDatasetSample.
static void createDatasetSample(String project, String datasetDisplayName, String metadataSchemaUri) 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";
LocationName locationName = LocationName.of(project, location);
Dataset dataset = Dataset.newBuilder().setDisplayName(datasetDisplayName).setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
System.out.format("Operation name: %s\n", datasetFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
Dataset datasetResponse = datasetFuture.get(300, TimeUnit.SECONDS);
System.out.println("Create Dataset Response");
System.out.format("Name: %s\n", datasetResponse.getName());
System.out.format("Display Name: %s\n", datasetResponse.getDisplayName());
System.out.format("Metadata Schema Uri: %s\n", datasetResponse.getMetadataSchemaUri());
System.out.format("Metadata: %s\n", datasetResponse.getMetadata());
System.out.format("Create Time: %s\n", datasetResponse.getCreateTime());
System.out.format("Update Time: %s\n", datasetResponse.getUpdateTime());
System.out.format("Labels: %s\n", datasetResponse.getLabelsMap());
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project java-aiplatform by googleapis.
the class CreateDatasetTextSample method createDatasetTextSample.
static void createDatasetTextSample(String project, String datasetDisplayName) 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 metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/text_1.0.0.yaml";
LocationName locationName = LocationName.of(project, location);
Dataset dataset = Dataset.newBuilder().setDisplayName(datasetDisplayName).setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
System.out.format("Operation name: %s\n", datasetFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
Dataset datasetResponse = datasetFuture.get(180, TimeUnit.SECONDS);
System.out.println("Create Text Dataset Response");
System.out.format("\tName: %s\n", datasetResponse.getName());
System.out.format("\tDisplay Name: %s\n", datasetResponse.getDisplayName());
System.out.format("\tMetadata Schema Uri: %s\n", datasetResponse.getMetadataSchemaUri());
System.out.format("\tMetadata: %s\n", datasetResponse.getMetadata());
System.out.format("\tCreate Time: %s\n", datasetResponse.getCreateTime());
System.out.format("\tUpdate Time: %s\n", datasetResponse.getUpdateTime());
System.out.format("\tLabels: %s\n", datasetResponse.getLabelsMap());
}
}
use of com.google.cloud.aiplatform.v1.Dataset in project OpenMUC by isc-konstanz.
the class Iec62056Connection method scanForChannels.
@Override
public List<ChannelScanInfo> scanForChannels(String settings) throws UnsupportedOperationException, ScanException, ConnectionException {
List<DataSet> dataSets;
DataMessage dataMessage;
try {
dataMessage = iec21Port.read();
} catch (IOException e) {
throw new ScanException(e);
}
dataSets = dataMessage.getDataSets();
if (dataSets == null) {
throw new ScanException("Read timeout.");
}
List<ChannelScanInfo> scanInfos = new ArrayList<>(dataSets.size());
for (DataSet dataSet : dataSets) {
try {
Double.parseDouble(dataSet.getValue());
scanInfos.add(new ChannelScanInfo(dataSet.getAddress(), "", ValueType.DOUBLE, null));
} catch (NumberFormatException e) {
scanInfos.add(new ChannelScanInfo(dataSet.getAddress(), "", ValueType.STRING, dataSet.getValue().length()));
}
}
return scanInfos;
}
Aggregations