Search in sources :

Example 11 with DataLabelingServiceClient

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

the class CreateInstructionIT method tearDown.

@After
public void tearDown() {
    System.setOut(null);
    bout.reset();
    // Delete the Instruction
    try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
        ProjectName projectName = ProjectName.of(PROJECT_ID);
        ListInstructionsRequest listRequest = ListInstructionsRequest.newBuilder().setParent(projectName.toString()).build();
        ListInstructionsPagedResponse response = dataLabelingServiceClient.listInstructions(listRequest);
        for (Instruction instruction : response.getPage().iterateAll()) {
            if (instruction.getDisplayName().equals("YOUR_INSTRUCTION_DISPLAY_NAME")) {
                dataLabelingServiceClient.deleteInstruction(instruction.getName());
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) ProjectName(com.google.cloud.datalabeling.v1beta1.ProjectName) IOException(java.io.IOException) Instruction(com.google.cloud.datalabeling.v1beta1.Instruction) ListInstructionsRequest(com.google.cloud.datalabeling.v1beta1.ListInstructionsRequest) ListInstructionsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListInstructionsPagedResponse) After(org.junit.After)

Example 12 with DataLabelingServiceClient

use of com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient 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();
    }
}
Also used : PrintStream(java.io.PrintStream) DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) ListDatasetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse) ProjectName(com.google.cloud.datalabeling.v1beta1.ProjectName) Dataset(com.google.cloud.datalabeling.v1beta1.Dataset) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ListDatasetsRequest(com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest) Before(org.junit.Before)

Example 13 with DataLabelingServiceClient

use of com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient 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();
    }
}
Also used : DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) ListDatasetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse) ProjectName(com.google.cloud.datalabeling.v1beta1.ProjectName) Dataset(com.google.cloud.datalabeling.v1beta1.Dataset) IOException(java.io.IOException) ListDatasetsRequest(com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest) After(org.junit.After)

Example 14 with DataLabelingServiceClient

use of com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient 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();
    }
}
Also used : ListAnnotationSpecSetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListAnnotationSpecSetsPagedResponse) PrintStream(java.io.PrintStream) DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) ListDatasetsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse) ProjectName(com.google.cloud.datalabeling.v1beta1.ProjectName) ListAnnotationSpecSetsRequest(com.google.cloud.datalabeling.v1beta1.ListAnnotationSpecSetsRequest) Dataset(com.google.cloud.datalabeling.v1beta1.Dataset) AnnotationSpecSet(com.google.cloud.datalabeling.v1beta1.AnnotationSpecSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Instruction(com.google.cloud.datalabeling.v1beta1.Instruction) IOException(java.io.IOException) ListDatasetsRequest(com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest) ListInstructionsRequest(com.google.cloud.datalabeling.v1beta1.ListInstructionsRequest) ListInstructionsPagedResponse(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListInstructionsPagedResponse) Before(org.junit.Before)

Example 15 with DataLabelingServiceClient

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

the class LabelTextIT method tearDown.

@After
public void tearDown() {
    System.setOut(null);
    // Delete the created dataset.
    try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create()) {
        dataLabelingServiceClient.deleteDataset(dataset.getName());
        dataLabelingServiceClient.deleteInstruction(instruction.getName());
        dataLabelingServiceClient.deleteAnnotationSpecSet(annotationSpecSet.getName());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) IOException(java.io.IOException) After(org.junit.After)

Aggregations

DataLabelingServiceClient (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient)19 IOException (java.io.IOException)19 ProjectName (com.google.cloud.datalabeling.v1beta1.ProjectName)11 DataLabelingServiceSettings (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceSettings)8 Dataset (com.google.cloud.datalabeling.v1beta1.Dataset)7 After (org.junit.After)7 ListDatasetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse)6 ListDatasetsRequest (com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest)6 ExecutionException (java.util.concurrent.ExecutionException)6 AnnotationSpecSet (com.google.cloud.datalabeling.v1beta1.AnnotationSpecSet)5 Instruction (com.google.cloud.datalabeling.v1beta1.Instruction)5 ListAnnotationSpecSetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListAnnotationSpecSetsPagedResponse)4 ListInstructionsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListInstructionsPagedResponse)4 ListAnnotationSpecSetsRequest (com.google.cloud.datalabeling.v1beta1.ListAnnotationSpecSetsRequest)4 ListInstructionsRequest (com.google.cloud.datalabeling.v1beta1.ListInstructionsRequest)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 Before (org.junit.Before)4 AnnotatedDataset (com.google.cloud.datalabeling.v1beta1.AnnotatedDataset)3 GcsSource (com.google.cloud.datalabeling.v1beta1.GcsSource)3