def main(argv):

    path = os.path.abspath('../../../') + "/resources/voc/test.xml"
    pascal_voc = PascalVocIO.parse_xml(path)
    validate_python(pascal_voc)
    print("test read VOC xml from python: Success")

    path = os.path.abspath('../../../') + "/resources/voc/2007_000027.xml"
    pascal_voc = PascalVocIO.parse_xml(path)
    validate_uk(pascal_voc)
    print("test read VOC xml from UK: Success")
Example #2
0
def test_read_voc_xml_with_empty_xml():
    path = os.path.abspath('../../../') + "/resources/voc/errorFiles/empty.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
    except Exception as e:
        print(e)
        assert ("Can't parse the XML file, no element found" in str(e)) is True
Example #3
0
def test_read_voc_xml_with_empty_object_difficult():
    path = os.path.abspath('../../../') + "/resources/voc/errorFiles/2007_000027_difficult_empty.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
    except Exception as e:
        print(e)
        assert ("Can't parse the XML file, object difficult can't be empty in VOC file!; The file is" in str(e)) is True
Example #4
0
def read_more_than_one_position_in_voc_part():
    path = os.path.abspath('../../../') + "/resources/voc/errorFiles/twoPosition_2007_000027.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
    except Exception as e:
        print(e)
        assert ("Can't parse the XML file, The number of object position type can't more than one "
              "in one object or one part, there are bndbox and circle in the object; The file is" in str(e)) is True
Example #5
0
def test_read_voc_xml_with_empty_annotation():
    path = os.path.abspath(
        '../../../') + "/resources/voc/errorFiles/emptyAnnotation.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
        assert True
    except Exception as e:
        print(e)
        assert False
Example #6
0
def test_read_voc_xml_with_empty_source():
    path = os.path.abspath(
        '../../../'
    ) + "/resources/voc/errorFiles/2007_000027_source_database_empty.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
        assert True
    except Exception as e:
        print(e)
        assert False
Example #7
0
def read_more_than_one_bndbox_in_voc():
    path = os.path.abspath(
        '../../../') + "/resources/voc/errorFiles/twoBndBox.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
    except Exception as e:
        print(e)
        assert (
            "Can't parse the XML file, The number of object bndbox can't more than one "
            "in one object or one part; The file is" in str(e)) is True
def test_read_voc_xml_label_properties_empty3():
    path = os.path.abspath(
        '../../../') + "/resources/voc/errorFiles/labelPropertiesEmpty3.xml"
    try:
        pascal_voc = PascalVocIO.parse_xml(path)
    except Exception as e:
        print(e)
        assert (
            "Can't parse the XML file, object properties color can't be empty in VOC file!; The file is"
            in str(e)) is True
Example #9
0
def main(argv):
    if len(argv) < 2:
        path = os.path.abspath(
            '../../../') + "/resources/voc/000000089955_1556180702627.xml"
        pascal_voc = PascalVocIO.parse_xml(path)
        validate(pascal_voc)
        print("test read local xml: Success")
    elif len(argv) < 3:
        path = argv[1]
        pascal_voc = PascalVocIO.parse_xml(path)
        validate(pascal_voc)
        print("test read local xml: Success")
    else:
        path = argv[1]
        ak = argv[2]
        sk = argv[3]
        endpoint = argv[4]
        pascal_voc = PascalVocIO.parse_xml(path, ak, sk, endpoint)
        validate(pascal_voc)
        print("test read OBS xml: Success")
def main(argv):
    path = os.path.abspath('../../../') + "/resources/voc/labelProperties.xml"
    pascal_voc = PascalVocIO.parse_xml(path)
    validate_voc_label_properties(pascal_voc)
def main(argv):
    if len(argv) < 2:
        path_base = os.path.abspath('../../../resources')
        path1 = path_base + "/detect-multi-local-voc.manifest"
        test_multi_default(path1)
        test_multi_exactly_match_type(path1)

        dataset = manifest.parse_manifest(path1)
        sample_num = dataset.get_size()
        for i in range(sample_num):
            sample = dataset.get_sample_list()[i]
            print("sample ", i)
            if len(sample.get_annotations()) == 1:
                validate_single_annotation_sample(sample)
                annotation = sample.get_annotations()[0]
                if "2007_000027" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2)
                    test_read_voc_xml_local.validate_uk(pascal_voc)
                    print("test read VOC xml from UK: Success")
                if "000000089955_1556180702627" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2)
                    test_read_voc_xml_local.validate(pascal_voc)
                    print("test read VOC xml: Success")
            else:
                annotations = sample.get_annotations()
                for annotation in annotations:
                    assert annotation.get_annotation_format() == "PASCAL VOC"
                    assert annotation.get_annotated_by() == "human"
                    assert annotation.get_type(
                    ) == "modelarts/object_detection"
                    if "2007_000027" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(path2)
                        test_read_voc_xml_local.validate_uk(pascal_voc)
                        print("test read VOC xml from UK: Success")
                    if "000000089955_1556180702627" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(path2)
                        test_read_voc_xml_local.validate(pascal_voc)
                        print("test read VOC xml: Success")
        print("test local Success")
    elif len(argv) < 3:
        path1 = argv[1]
        path_base = path1[:path1.rfind('/')]
        test_multi_default(path1)
        test_multi_exactly_match_type(path1)

        dataset = manifest.parse_manifest(path1)
        sample_num = dataset.get_size()
        for i in range(sample_num):
            sample = dataset.get_sample_list()[i]
            print("sample ", i)
            if len(sample.get_annotations()) == 1:
                validate_single_annotation_sample(sample)
                annotation = sample.get_annotations()[0]
                if "2007_000027" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2)
                    test_read_voc_xml_local.validate_uk(pascal_voc)
                    print("test read VOC xml from UK: Success")
                if "000000089955_1556180702627" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2)
                    test_read_voc_xml_local.validate(pascal_voc)
                    print("test read VOC xml: Success")
            else:
                annotations = sample.get_annotations()
                for annotation in annotations:
                    assert annotation.get_annotation_format() == "PASCAL VOC"
                    assert annotation.get_annotated_by() == "human"
                    assert annotation.get_type(
                    ) == "modelarts/object_detection"
                    if "2007_000027" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(path2)
                        test_read_voc_xml_local.validate_uk(pascal_voc)
                        print("test read VOC xml from UK: Success")
                    if "000000089955_1556180702627" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(path2)
                        test_read_voc_xml_local.validate(pascal_voc)
                        print("test read VOC xml: Success")
    else:
        path_base = "s3://obs-dataset-sjy"
        path1 = path_base + "/detect-multi-local-voc.manifest"
        ak = argv[1]
        sk = argv[2]
        endpoint = argv[3]
        test_multi_default(path1, ak, sk, endpoint)
        test_multi_exactly_match_type(path1, ak, sk, endpoint)

        dataset = manifest.parse_manifest(path1, ak, sk, endpoint)
        sample_num = dataset.get_size()
        for i in range(sample_num):
            sample = dataset.get_sample_list()[i]
            print("sample ", i)
            if len(sample.get_annotations()) == 1:
                validate_single_annotation_sample(sample)
                annotation = sample.get_annotations()[0]
                if "2007_000027" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2, ak, sk, endpoint)
                    test_read_voc_xml_local.validate_uk(pascal_voc)
                    print("test read VOC xml from UK: Success")
                if "000000089955_1556180702627" in annotation.get_loc():
                    path2 = path_base + annotation.get_loc()[1:]
                    pascal_voc = PascalVocIO.parse_xml(path2, ak, sk, endpoint)
                    test_read_voc_xml_local.validate(pascal_voc)
                    print("test read VOC xml: Success")
            else:
                annotations = sample.get_annotations()
                for annotation in annotations:
                    assert annotation.get_annotation_format() == "PASCAL VOC"
                    assert annotation.get_annotated_by() == "human"
                    assert annotation.get_type(
                    ) == "modelarts/object_detection"
                    if "2007_000027" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(
                            path2, ak, sk, endpoint)
                        test_read_voc_xml_local.validate_uk(pascal_voc)
                        print("test read VOC xml from UK: Success")
                    if "000000089955_1556180702627" in annotation.get_loc():
                        path2 = path_base + annotation.get_loc()[1:]
                        pascal_voc = PascalVocIO.parse_xml(
                            path2, ak, sk, endpoint)
                        test_read_voc_xml_local.validate(pascal_voc)
                        print("test read VOC xml: Success")
        print("test OBS Success")
def main(argv):
    path = os.path.abspath(
        '../../../') + "/resources/voc/000000115967_1556247179208.xml"
    pascal_voc = PascalVocIO.parse_xml(path)
    validate_voc_multiple_object(pascal_voc)