use of com.google.cloud.automl.v1.Dataset in project OpenMUC by isc-konstanz.
the class IecConnection method read.
@Override
public void read(List<ChannelRecordContainer> containers, int timeout) throws ConnectionException {
logger.trace("reading channels");
long timestamp = System.currentTimeMillis();
try {
byte[] frame = receiver.receiveMessage(timeout);
ModeDMessage message = ModeDMessage.parse(frame);
List<String> dataSets = message.getDataSets();
Map<String, Value> values = new LinkedHashMap<>();
for (String ds : dataSets) {
DataSet dataSet = new DataSet(ds);
String address = dataSet.getAddress();
Value value = dataSet.parseValueAsDouble();
values.put(address, value);
logger.trace("{} = {}", address, value);
}
handleChannelRecordContainer(containers, values, timestamp);
} catch (IOException e) {
logger.error("read failed", e);
disconnect();
throw new ConnectionException(e);
} catch (ParseException e) {
logger.error("parsing failed", e);
}
}
use of com.google.cloud.automl.v1.Dataset in project java-datalabeling by googleapis.
the class CreateDatasetIT method tearDown.
@After
public void tearDown() {
System.setOut(null);
bout.reset();
// Delete the Dataset
try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
ProjectName projectName = ProjectName.of(PROJECT_ID);
ListDatasetsRequest listRequest = ListDatasetsRequest.newBuilder().setParent(projectName.toString()).build();
ListDatasetsPagedResponse response = dataLabelingServiceClient.listDatasets(listRequest);
for (Dataset dataset : response.getPage().iterateAll()) {
if (dataset.getDisplayName().equals(datasetName)) {
dataLabelingServiceClient.deleteDataset(dataset.getName());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.google.cloud.automl.v1.Dataset in project java-datalabeling by googleapis.
the class ImportDataIT method setUp.
@Before
public void setUp() throws IOException {
bout = new ByteArrayOutputStream();
System.setOut(new PrintStream(bout));
CreateDataset.createDataset(PROJECT_ID, datasetName);
// Get the Dataset
try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
ProjectName projectName = ProjectName.of(PROJECT_ID);
ListDatasetsRequest listRequest = ListDatasetsRequest.newBuilder().setParent(projectName.toString()).build();
ListDatasetsPagedResponse response = dataLabelingServiceClient.listDatasets(listRequest);
for (Dataset returnedDataset : response.getPage().iterateAll()) {
if (returnedDataset.getDisplayName().equals("IMPORT_DATASET_NAME")) {
dataset = returnedDataset;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.google.cloud.automl.v1.Dataset in project java-datalabeling by googleapis.
the class ImportDataIT method tearDown.
@After
public void tearDown() {
System.setOut(null);
bout.reset();
// Delete the Dataset
try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
ProjectName projectName = ProjectName.of(PROJECT_ID);
ListDatasetsRequest listRequest = ListDatasetsRequest.newBuilder().setParent(projectName.toString()).build();
ListDatasetsPagedResponse response = dataLabelingServiceClient.listDatasets(listRequest);
for (Dataset returnedDataset : response.getPage().iterateAll()) {
if (returnedDataset.getDisplayName().equals("IMPORT_DATASET_NAME")) {
dataLabelingServiceClient.deleteDataset(returnedDataset.getName());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.google.cloud.automl.v1.Dataset in project java-datalabeling by googleapis.
the class LabelImageIT method setUp.
@Before
public void setUp() {
System.setOut(new PrintStream(new ByteArrayOutputStream()));
try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
// Create the dataset
CreateDataset.createDataset(PROJECT_ID, datsetName);
ProjectName projectName = ProjectName.of(PROJECT_ID);
// Get the Dataset
ListDatasetsRequest datasetsRequest = ListDatasetsRequest.newBuilder().setParent(projectName.toString()).build();
ListDatasetsPagedResponse datasetsResponse = dataLabelingServiceClient.listDatasets(datasetsRequest);
for (Dataset returnedDataset : datasetsResponse.getPage().iterateAll()) {
if (returnedDataset.getDisplayName().equals("LABEL_IMAGE_DATASET_NAME")) {
dataset = returnedDataset;
}
}
// Import the images
ImportData.importData(dataset.getName(), DATASET_GCS_SOURCE_URI);
// Create the instruction
CreateInstruction.createInstruction(PROJECT_ID, INSTRUCTION_GCS_SOURCE_URI);
// Create the annotation spec set
CreateAnnotationSpecSet.createAnnotationSpecSet(PROJECT_ID);
// Get the instruction
ListInstructionsRequest instructionsRequest = ListInstructionsRequest.newBuilder().setParent(projectName.toString()).build();
ListInstructionsPagedResponse instructionsResponse = dataLabelingServiceClient.listInstructions(instructionsRequest);
for (Instruction returnedInstruction : instructionsResponse.getPage().iterateAll()) {
if (returnedInstruction.getDisplayName().equals("YOUR_INSTRUCTION_DISPLAY_NAME")) {
instruction = returnedInstruction;
}
}
// Get the annotation spec set
ListAnnotationSpecSetsRequest annotationRequest = ListAnnotationSpecSetsRequest.newBuilder().setParent(projectName.toString()).build();
ListAnnotationSpecSetsPagedResponse annotationsResponse = dataLabelingServiceClient.listAnnotationSpecSets(annotationRequest);
for (AnnotationSpecSet returnedAnnotation : annotationsResponse.getPage().iterateAll()) {
if (returnedAnnotation.getDisplayName().equals("YOUR_ANNOTATION_SPEC_SET_DISPLAY_NAME")) {
annotationSpecSet = returnedAnnotation;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations