Exemple #1
0
import image_utils

if __name__ == '__main__':

    ensure_dir(conf.DATA_DIR)
    ensure_dir(conf.ANNOTATION_DIR)
    ensure_dir(conf.PNG_DIR)
    ensure_dir(conf.TILE_PNG_DIR)
    ttl_objs = 0

    try:

        label_map_dict = label_map_util.get_label_map_dict(
            conf.LABEL_PATH_PATH)
        a = Annotation(conf.CLEAN_FILE, conf.GROUP_FILE, None)
        a.generate_tiles()
        a.aggregate()

        for key, data in a.get_dict().items():
            print('Key {0}'.format(key))
            try:
                xml = dicttoxml(data,
                                custom_root='annotation',
                                attr_type=False)

                # dicttoxml doesn't quite put the xml into the correct format for TF
                # remove tag object, and replace each child tag item with object
                root = etree.fromstring(xml)
                etree.strip_tags(root, 'object')
                for element in root.getiterator():
                    if 'item' in element.tag: