diff --git a/README.md b/README.md index c42a0084..f1e7b2d2 100644 --- a/README.md +++ b/README.md @@ -263,13 +263,19 @@ Use cases: image object detection ### YOLO to Label Studio converter -Usage: +Object detection usage: ``` label-studio-converter import yolo -i /yolo/root/directory -o ls-tasks.json ``` -Help: +Semantic segmentation usage: + +``` +label-studio-converter import yolo-seg -i /yolo/root/directory -o ls-tasks.json +``` + +Help (same for semantic segmentation): ``` label-studio-converter import yolo -h diff --git a/label_studio_converter/imports/yolo_seg.py b/label_studio_converter/imports/yolo_seg.py new file mode 100644 index 00000000..0bea0c69 --- /dev/null +++ b/label_studio_converter/imports/yolo_seg.py @@ -0,0 +1,214 @@ +import os +import json # better to use "imports ujson as json" for the best performance + +import uuid +import logging + +from PIL import Image +from typing import Optional, Tuple +from urllib.request import ( + pathname2url, +) # for converting "+","*", etc. in file paths to appropriate urls + +from label_studio_converter.utils import ExpandFullPath +from label_studio_converter.imports.label_config import generate_label_config + +logger = logging.getLogger('root') + + +def convert_yolo_seg_to_ls( + input_dir, + out_file, + to_name='image', + from_name='label', + out_type="annotations", + image_root_url='/data/local-files/?d=', + image_ext='.jpg,.jpeg,.png', + image_dims: Optional[Tuple[int, int]] = None, +): + """Convert YOLO labeling to Label Studio JSON + :param input_dir: directory with YOLO where images, labels, notes.json are located + :param out_file: output file with Label Studio JSON tasks + :param to_name: object name from Label Studio labeling config + :param from_name: control tag name from Label Studio labeling config + :param out_type: annotation type - "annotations" or "predictions" + :param image_root_url: root URL path where images will be hosted, e.g.: http://example.com/images + :param image_ext: image extension/s - single string or comma separated list to search, eg. .jpeg or .jpg, .png and so on. + :param image_dims: image dimensions - optional tuple of integers specifying the image width and height of *all* images in the dataset. Defaults to opening the image to determine it's width and height, which is slower. This should only be used in the special case where you dataset has uniform image dimesions. + """ + + tasks = [] + logger.info('Reading YOLO notes and categories from %s', input_dir) + + # build categories=>labels dict + notes_file = os.path.join(input_dir, 'classes.txt') + with open(notes_file) as f: + lines = [line.strip() for line in f.readlines()] + categories = {i: line for i, line in enumerate(lines)} + logger.info(f'Found {len(categories)} categories') + + # generate and save labeling config + label_config_file = out_file.replace('.json', '') + '.label_config.xml' + generate_label_config( + categories, + {from_name: 'PolygonLabels'}, + to_name, + from_name, + label_config_file, + ) + + # define directories + labels_dir = os.path.join(input_dir, 'labels') + images_dir = os.path.join(input_dir, 'images') + logger.info('Converting labels from %s', labels_dir) + + # build array out of provided comma separated image_extns (str -> array) + image_ext = [x.strip() for x in image_ext.split(",")] + logger.info(f'image extensions->, {image_ext}') + + # loop through images + for f in os.listdir(images_dir): + image_file_found_flag = False + for ext in image_ext: + if f.endswith(ext): + image_file = f + image_file_base = f[0 : -len(ext)] + image_file_found_flag = True + break + if not image_file_found_flag: + continue + + image_root_url += '' if image_root_url.endswith('/') else '/' + task = { + "data": { + # eg. '../../foo+you.py' -> '../../foo%2Byou.py' + "image": image_root_url + + str(pathname2url(image_file)) + } + } + + # define coresponding label file and check existence + label_file = os.path.join(labels_dir, image_file_base + '.txt') + + if os.path.exists(label_file): + task[out_type] = [ + { + "result": [], + "ground_truth": False, + } + ] + + # read image sizes + if image_dims is None: + # default to opening file if we aren't given image dims. slow! + with Image.open(os.path.join(images_dir, image_file)) as im: + image_width, image_height = im.size + else: + image_width, image_height = image_dims + + with open(label_file) as file: + # convert all polygons to Label Studio Results + lines = file.readlines() + for line in lines: + label_id, *label_coords = line.split() + label_coords = [float(coord) * 100 for coord in label_coords] + vertices_xy = [label_coords[i: i + 2] for i in range(0, len(label_coords), 2)] + + item = { + "id": uuid.uuid4().hex[0:10], + "type": "polygonlabels", + "value": { + "points": vertices_xy, + "closed": True, + "polygonlabels": [categories[int(label_id)]], + }, + "to_name": to_name, + "from_name": from_name, + "image_rotation": 0, + "original_width": image_width, + "original_height": image_height + } + task[out_type][0]["result"].append(item) + + tasks.append(task) + + if len(tasks) > 0: + logger.info('Saving Label Studio JSON to %s', out_file) + with open(out_file, 'w') as out: + json.dump(tasks, out) + + print( + '\n' + f' 1. Create a new project in Label Studio\n' + f' 2. Use Labeling Config from "{label_config_file}"\n' + f' 3. Setup serving for images [e.g. you can use Local Storage (or others):\n' + f' https://labelstud.io/guide/storage.html#Local-storage]\n' + f' 4. Import "{out_file}" to the project\n' + ) + else: + logger.error('No labels converted') + + +def add_parser(subparsers): + yolo_seg = subparsers.add_parser('yolo-seg') + + yolo_seg.add_argument( + '-i', + '--input', + dest='input', + required=True, + help='directory with YOLO where images, labels, notes.json are located', + action=ExpandFullPath, + ) + yolo_seg.add_argument( + '-o', + '--output', + dest='output', + help='output file with Label Studio JSON tasks', + default='output.json', + action=ExpandFullPath, + ) + yolo_seg.add_argument( + '--to-name', + dest='to_name', + help='object name from Label Studio labeling config', + default='image', + ) + yolo_seg.add_argument( + '--from-name', + dest='from_name', + help='control tag name from Label Studio labeling config', + default='label', + ) + yolo_seg.add_argument( + '--out-type', + dest='out_type', + help='annotation type - "annotations" or "predictions"', + default='annotations', + ) + yolo_seg.add_argument( + '--image-root-url', + dest='image_root_url', + help='root URL path where images will be hosted, e.g.: http://example.com/images', + default='/data/local-files/?d=', + ) + yolo_seg.add_argument( + '--image-ext', + dest='image_ext', + help='image extension to search: .jpeg or .jpg, .png', + default='.jpg', + ) + yolo_seg.add_argument( + '--image-dims', + dest='image_dims', + type=int, + nargs=2, + help=( + "optional tuple of integers specifying the image width and height of *all* " + "images in the dataset. Defaults to opening the image to determine it's width " + "and height, which is slower. This should only be used in the special " + "case where you dataset has uniform image dimesions. e.g. `--image-dims 600 800` " + "if all your images are of dimensions width=600, height=800" + ), + default=None, + ) diff --git a/label_studio_converter/main.py b/label_studio_converter/main.py index 2eba0678..dd65b4ed 100644 --- a/label_studio_converter/main.py +++ b/label_studio_converter/main.py @@ -6,7 +6,7 @@ from label_studio_converter.converter import Converter, Format, FormatNotSupportedError from label_studio_converter.exports.csv import ExportToCSV from label_studio_converter.utils import ExpandFullPath -from label_studio_converter.imports import yolo as import_yolo, coco as import_coco +from label_studio_converter.imports import yolo as import_yolo, yolo_seg as import_yolo_seg, coco as import_coco logging.basicConfig(level=logging.INFO) @@ -97,6 +97,7 @@ def get_all_args(): ) import_format = parser_import.add_subparsers(dest='import_format') import_yolo.add_parser(import_format) + import_yolo_seg.add_parser(import_format) import_coco.add_parser(import_format) return parser.parse_args() @@ -166,6 +167,17 @@ def imports(args): image_root_url=args.image_root_url, image_ext=args.image_ext, ) + + elif args.import_format == 'yolo-seg': + import_yolo_seg.convert_yolo_seg_to_ls( + input_dir=args.input, + out_file=args.output, + to_name=args.to_name, + from_name=args.from_name, + out_type=args.out_type, + image_root_url=args.image_root_url, + image_ext=args.image_ext, + ) elif args.import_format == 'coco': import_coco.convert_coco_to_ls( diff --git a/tests/data/test_import_yolo_seg_data/classes.txt b/tests/data/test_import_yolo_seg_data/classes.txt new file mode 100644 index 00000000..979491c7 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/classes.txt @@ -0,0 +1,4 @@ +closed_door +opened_door +bus +number diff --git a/tests/data/test_import_yolo_seg_data/images/img_1.jpg b/tests/data/test_import_yolo_seg_data/images/img_1.jpg new file mode 100644 index 00000000..b44e1108 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_1.jpg differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_2.png b/tests/data/test_import_yolo_seg_data/images/img_2.png new file mode 100644 index 00000000..6f15b841 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_2.png differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_3.png b/tests/data/test_import_yolo_seg_data/images/img_3.png new file mode 100644 index 00000000..e63dcda4 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_3.png differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_4.png b/tests/data/test_import_yolo_seg_data/images/img_4.png new file mode 100644 index 00000000..6f72e596 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_4.png differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_5.jpg b/tests/data/test_import_yolo_seg_data/images/img_5.jpg new file mode 100644 index 00000000..567beb84 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_5.jpg differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_6.jpeg b/tests/data/test_import_yolo_seg_data/images/img_6.jpeg new file mode 100644 index 00000000..812e0175 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_6.jpeg differ diff --git a/tests/data/test_import_yolo_seg_data/images/img_7.jpeg b/tests/data/test_import_yolo_seg_data/images/img_7.jpeg new file mode 100644 index 00000000..2b57b3d8 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data/images/img_7.jpeg differ diff --git a/tests/data/test_import_yolo_seg_data/labels/img_1.txt b/tests/data/test_import_yolo_seg_data/labels/img_1.txt new file mode 100644 index 00000000..4631a442 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_1.txt @@ -0,0 +1,4 @@ +2 0.0633721205070745 0.08960138500340462 0.05533468083300653 0.1070405807423223 0.046678976568625616 0.18461493420164576 0.037714140009088244 0.2970676791388046 0.03153149410595902 0.3938852830686579 0.028749303449550866 0.499121809079368 0.027203641973768566 0.5911286003915888 0.02844017115439441 0.6819326885494016 0.03400455246721071 0.7709327219756021 0.035241081647836556 0.8388377773093125 0.03678674312361886 0.8586823793570464 0.043587653617061 0.8683040045923114 0.10665064182897904 0.874317520364352 0.11190589084663888 0.8791283329819843 0.2559615403895497 0.8899526613716574 0.35921172697180764 0.8989729350297183 0.38270578140369876 0.9037837476473507 0.423202112069195 0.8977702318753102 0.4541153415848412 0.8911553645260656 0.4902838201181472 0.8779256298275763 0.5041947734001879 0.8779256298275763 0.5100682870081605 0.9031823960701466 0.5233609756998884 0.9200202402318602 0.5397449873431809 0.9152094276142279 0.5514920145591264 0.8941621224120857 0.5607659834138202 0.8610877856658626 0.5774591273522691 0.8496621056989855 0.6195011194935479 0.8334256131144762 0.6553604657316973 0.8213985815703948 0.6862736952473435 0.8099729016035176 0.718114321648459 0.8003512763682528 0.7450088313270711 0.7901282995557838 0.7802499129749075 0.781709377474927 0.812090539376023 0.7696823459308458 0.84640422413839 0.761263423849989 0.8525868700415196 0.7889255964013757 0.8658795587332472 0.8021553310998649 0.8748443952927846 0.7955404637506203 0.879790512015288 0.77028369750805 0.8835000995571655 0.7462296344198875 0.9147224613679683 0.7366080091846228 0.9379073835047026 0.728189087103766 0.9715598288456058 0.6957161019347466 0.9727963580262313 0.6229525610930557 0.9715598288456054 0.5435741529021202 0.9703232996649797 0.47020926048322503 0.9693959027795104 0.37519571128498397 0.968468505894041 0.282587568395559 0.9666137121231021 0.17795239396205292 0.9595036693345037 0.16472265926356364 0.9131338250610345 0.1569050887599109 0.8593448057038102 0.14608076037023787 0.8040101248708037 0.13645913513497296 0.7517667669893617 0.12743886147691208 0.6967412184515118 0.11726355755479129 0.6370786854863147 0.10643922916511822 0.5789618139969 0.09501354919824113 0.5242453977542065 0.08719597869458838 0.48776778692574413 0.08238516607695592 0.4383066197007104 0.07637165030491536 0.40028334739646565 0.07035813453287476 0.3585504875503434 0.06254056402922202 0.3189815537703164 0.0571283998343855 0.27415737097262954 0.0541216419483652 0.21855653267561792 0.0541216419483652 0.1765145405343392 0.05772975141158956 0.13509081298337347 0.06494597033803824 0.08995749789053015 0.0781757050365275 +0 0.3913081473705955 0.2077395452853236 0.42526224388285544 0.21093553828971323 0.46140692726687405 0.21306620029263962 0.49207514347149584 0.21519686229556606 0.4945910723225618 0.3550514436146151 0.4940932116698893 0.48773357743321344 0.49508893297523426 0.5874872984793128 0.49508893297523426 0.6882095022540152 0.496084654280579 0.7618141896278362 0.497080375585924 0.848009152473495 0.44928575292937056 0.8605994279453328 0.39501894178807545 0.8848114961604054 0.3935253598300581 0.7569717759848218 0.3945210811354031 0.6194472285232089 0.3940232204827305 0.5138826111054919 0.39153391721936837 0.3821689600154965 0.391036056566696 0.2814467562407942 +0 0.7565461408431807 0.23786503345366333 0.7874135013088714 0.23786503345366333 0.8217658863432692 0.24173896436807496 0.8222637469959416 0.34149268541417444 0.823757328953959 0.42381371734542156 0.824753050259304 0.5332522656775501 0.824753050259304 0.6572180549387222 0.8267444928699936 0.7482554314273956 0.7963749930569751 0.7608457068992333 0.7615247473699049 0.7695620514566595 0.7615247473699049 0.6562495722101194 0.7620226080225774 0.5690861266358577 0.7590354441065428 0.47223785377556693 0.7575418621485255 0.37054716727226167 +3 0.26465981600281774 0.1129307614638883 0.26117479143411076 0.22140082706741387 0.31593946322807825 0.22140082706741387 0.32191379106014745 0.10808834782087376 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_2.txt b/tests/data/test_import_yolo_seg_data/labels/img_2.txt new file mode 100644 index 00000000..15d153bc --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_2.txt @@ -0,0 +1,4 @@ +2 0.8570140867160779 0.29644290501897036 0.7891087120622501 0.287059067307079 0.7298721086408257 0.27839706326533303 0.6706355052194016 0.2791188969354785 0.6118805001997775 0.27984073060562403 0.54493832234955 0.2863372336369334 0.4582506100255145 0.3180979151233352 0.3763788817194809 0.3476930955993005 0.30076793263685 0.3736791077245383 0.2434577228226265 0.3953341178289031 0.21648821232181542 0.4025524545303581 0.21070903150021308 0.45957731447185224 0.2092642362948125 0.5418663528684386 0.20733784268761168 0.6494195697201174 0.20733784268761168 0.715828267373503 0.23671534519742374 0.7461452815196137 0.25164489565322984 0.7504762835404866 0.25068169884962943 0.7721312936448517 0.2564608796712318 0.7721312936448517 0.259350470082033 0.785846133377616 0.26705604451083614 0.7930644700790708 0.2771696109486403 0.77718412933587 0.2805407997612417 0.7569727865717961 0.3368878127718647 0.7742967946552881 0.3797500705320823 0.7872898007179068 0.42550191870310106 0.7973954720999439 0.45247142920391215 0.8046138088013987 0.4563242164183137 0.837096323957946 0.4664377828561178 0.8616386687428929 0.488591309338927 0.8616386687428929 0.4982232773749309 0.8392618249683825 0.49918647417853124 0.8132758128431448 0.5304903702955441 0.8255469852356182 0.586355784904367 0.837096323957946 0.6301812394681849 0.8385399912982371 0.6985682125238131 0.8392618249683825 0.7236113294174232 0.8378181576280916 0.7332432974534272 0.8486456626802739 0.7650287919722402 0.854420332041438 0.7761055552136447 0.8378181576280916 0.7982590816964538 0.8349308229475095 0.8016302705090552 0.8125539791729992 0.842566134662072 0.8190504822043088 0.8748332275826853 0.8132758128431448 0.8859099908240898 0.8031701414611078 0.8878363844312903 0.7569727865717961 0.8690540467610828 0.7461452815196137 0.8700172435646834 0.6790147501960827 0.8690540467610828 0.6097187178621151 0.8685724483592826 0.5252641784550922 0.8661644563502816 0.4335913023466144 0.8637564643412806 0.37440094139468383 +0 0.4857017189281258 0.3902812821378847 0.5280823782865431 0.37656644240512027 0.5300087718937438 0.4104926249019585 0.5256743862775421 0.5332043488266928 0.5261559846793423 0.6025003811606602 0.5271191814829427 0.7194374357242305 0.5309719686973443 0.8082229771521263 0.4857017189281258 0.7973954720999439 0.4881097109371267 0.6833457522169557 0.488591309338927 0.559912194622076 0.48666491573172604 0.4718484868643257 +0 0.2949887518152476 0.43864413803763286 0.32051346711065803 0.4328694686764689 0.31810547510165704 0.5389790181878567 0.3161790814944563 0.6515850707305539 0.31762387669985687 0.7490326162001957 0.2940255550116472 0.7439797805091772 0.2925807598062466 0.6530287380708448 0.2940255550116472 0.575792535365277 0.293543956609847 0.49999999999999994 +3 0.5849109896989664 0.3029394080502798 0.5844293912971663 0.35563326597090095 0.6070645161817755 0.35707693331119195 0.608509311387176 0.30149574070998886 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_3.txt b/tests/data/test_import_yolo_seg_data/labels/img_3.txt new file mode 100644 index 00000000..6b34e7ba --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_3.txt @@ -0,0 +1,4 @@ +3 0.2644538903363631 0.20499629894854596 0.26521803018928647 0.25593895581010573 0.29731190401206903 0.25729742665974725 0.29616569423268396 0.2043170635237252 +0 0.1535921104376025 0.2518635432611809 0.179572865436998 0.24235424731368976 0.18110114514284475 0.3272586754162893 0.17919079551053627 0.4338986371131542 0.18186528499576815 0.5452932467837648 0.1574128097022195 0.5364631862610945 0.15168176080529402 0.4325401662635127 0.15550246006991103 0.33608873593895955 +0 0.07717812514526295 0.2769952539795504 0.09398920190957767 0.27020289973134237 0.09246092220373088 0.374805155153745 0.09475334176250104 0.4705773500534773 0.08214503418926505 0.46989811462865644 0.07947054470403314 0.37548439057856586 +2 0.4233334785195612 0.1866569424783845 0.39544237388785725 0.1689968214330438 0.35799952109461086 0.1608459963351942 0.3136794096250539 0.15473287751180706 0.27012343800842037 0.15677058378626946 0.23764749425917608 0.16763835058340215 0.19485566249546588 0.18597770705356367 0.14671485176129195 0.20975094692229157 0.1043050899240435 0.23012800966691543 0.08061675448341825 0.24303348273851058 0.07221121610126088 0.26001436835903047 0.07182914617479919 0.35239038613465873 0.07297535595418428 0.4325401662635127 0.07373949580710767 0.4739735271775812 0.07443104237400336 0.5188132537471261 0.09754627292493608 0.5278538772514909 0.10216931903512264 0.5664819958610495 0.12019919886485014 0.5845632428697792 0.1317568141403165 0.5673038707250827 0.14100290636068957 0.5541538729005522 0.2117355118465437 0.5853851177338124 0.21635855795673029 0.6182601122951389 0.23300152395340176 0.6281226106635368 0.24964448995007338 0.624013236343371 0.2547298406712786 0.5919601166460776 0.25889058217044647 0.573878869637348 0.3698436888149235 0.5516882483084526 0.37307982109205406 0.5722351199092817 0.38787356864465106 0.5845632428697792 0.4045165346413226 0.5796319936855803 0.41283801763965833 0.5541538729005522 0.414687236083733 0.5410038750760214 0.44843547268809475 0.5286757521155241 0.4488977772991134 0.43498201761574345 0.44288781735587096 0.37169765308518987 0.43364172513549787 0.28868829181784034 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_4.txt b/tests/data/test_import_yolo_seg_data/labels/img_4.txt new file mode 100644 index 00000000..2a3a60e0 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_4.txt @@ -0,0 +1,4 @@ +3 0.3869245524296675 0.5396419437340153 0.3553388746803069 0.5383631713554987 0.3573129795396419 0.5767263427109974 0.3859375 0.5754475703324808 +0 0.437264226342711 0.6406649616368285 0.435290121483376 0.7762148337595908 0.4333160166240409 0.9232736572890026 0.5004355818414322 0.9232736572890026 0.5004355818414322 0.782608695652174 0.5014226342710998 0.649616368286445 +0 0.615920716112532 0.6624040920716112 0.6139466112531969 0.7851662404092071 0.6109854539641943 0.9181585677749361 0.6692215473145781 0.9194373401534527 0.6672474424552429 0.7902813299232737 0.6702085997442455 0.6713554987212276 +2 0.21221627237851665 0.3734015345268542 0.18951406649616367 0.530690537084399 0.18260469948849106 0.7135549872122762 0.17865648976982096 0.8785166240409207 0.180630594629156 0.9143222506393862 0.2803228900255754 0.9258312020460358 0.2990768861892583 0.9552429667519181 0.3267143542199489 0.9616368286445013 0.3425071930946292 0.9322250639386189 0.4481218030690537 0.9386189258312021 0.47279811381074166 0.9450127877237852 0.4895780051150895 0.9654731457800512 0.5211636828644501 0.9705882352941176 0.5409047314578005 0.9386189258312021 0.7077165920716113 0.9309462915601023 0.7264705882352941 0.9526854219948849 0.7629915281329923 0.9539641943734015 0.8044477301790282 0.9526854219948849 0.815305306905371 0.9245524296675192 0.8656449808184143 0.9156010230179028 0.8666320332480818 0.7813299232736572 0.8676190856777494 0.643222506393862 0.8616967710997443 0.4846547314578005 0.6899496483375959 0.4309462915601023 0.5251118925831202 0.38235294117647056 0.43923833120204603 0.35421994884910485 0.32276614450127883 0.3491048593350384 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_5.txt b/tests/data/test_import_yolo_seg_data/labels/img_5.txt new file mode 100644 index 00000000..51a32ed8 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_5.txt @@ -0,0 +1,3 @@ +2 0.14096467391304346 0.24040920716112532 0.1511548913043478 0.3350383631713555 0.14096467391304346 0.5626598465473146 0.1324728260869565 0.5818414322250639 0.1358695652173913 0.7429667519181585 0.020380434782608692 0.7608695652173914 0.001698369565217391 0.7506393861892583 0.001698369565217391 0.21483375959079287 0.016134510869565216 0.21099744245524296 +2 0.9154211956521737 0.34782608695652173 0.9196671195652173 0.5358056265984654 0.9213654891304347 0.6521739130434783 0.8916440217391304 0.6892583120204604 0.8602241847826086 0.6943734015345268 0.8466372282608695 0.7352941176470589 0.8288043478260867 0.7429667519181585 0.8152173913043478 0.717391304347826 0.6725543478260869 0.7685421994884911 0.6436820652173912 0.8222506393861893 0.6097146739130435 0.8491048593350383 0.588485054347826 0.8184143222506394 0.4619565217391304 0.8670076726342711 0.4279891304347825 0.8554987212276215 0.373641304347826 0.8363171355498722 0.16219429347826084 0.782608695652174 0.14181385869565216 0.7864450127877238 0.13671874999999997 0.7672634271099744 0.13671874999999997 0.670076726342711 0.1333220108695652 0.578005115089514 0.1537024456521739 0.3350383631713555 0.14521059782608695 0.30818414322250637 0.14351222826086954 0.19820971867007672 0.24966032608695649 0.1547314578005115 0.41015624999999994 0.11508951406649617 0.4415760869565217 0.13171355498721227 0.6997282608695652 0.24808184143222506 +0 0.4475203804347825 0.26342710997442453 0.5867866847826086 0.30434782608695654 0.5876358695652173 0.7966751918158568 0.45091711956521735 0.8363171355498722 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_6.txt b/tests/data/test_import_yolo_seg_data/labels/img_6.txt new file mode 100644 index 00000000..2e4e5305 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_6.txt @@ -0,0 +1,4 @@ +3 0.3104013104013104 0.3771043771043771 0.31122031122031124 0.43825643825643823 0.3464373464373464 0.4426244426244426 0.34807534807534807 0.37419237419237417 +0 0.0900900900900901 0.24024024024024024 0.29238329238329236 0.24897624897624898 0.28255528255528256 0.7702247702247702 0.08026208026208026 0.7760487760487762 +1 0.7477477477477479 0.281008281008281 0.9385749385749385 0.29120029120029123 0.9107289107289107 0.7687687687687688 0.7362817362817363 0.765856765856766 +2 0.9975429975429975 0.1892801892801893 0.5282555282555282 0.16889616889616887 0.002457002457002457 0.1426881426881427 0.0032760032760032766 0.7644007644007644 0.07698607698607698 0.7876967876967877 0.34152334152334146 0.7745927745927745 0.3988533988533989 0.8401128401128402 0.45782145782145783 0.8372008372008373 0.4873054873054873 0.7775047775047775 0.7231777231777232 0.7775047775047775 0.9983619983619983 0.778960778960779 diff --git a/tests/data/test_import_yolo_seg_data/labels/img_7.txt b/tests/data/test_import_yolo_seg_data/labels/img_7.txt new file mode 100644 index 00000000..b0d00634 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data/labels/img_7.txt @@ -0,0 +1,2 @@ +2 0.20988251278772377 0.3491048593350384 0.20732296994884908 0.4053708439897698 0.21158887468030688 0.5613810741687979 0.20732296994884908 0.6636828644501278 0.18940617007672633 0.6751918158567775 0.18855298913043478 0.7109974424552431 0.36772098785166235 0.7263427109974424 0.482900415601023 0.7135549872122762 0.5008172154731457 0.7378516624040921 0.5289721867007672 0.7378516624040921 0.5443294437340153 0.7020460358056266 0.7021679187979539 0.673913043478261 0.824172794117647 0.6483375959079284 0.8369705083120204 0.6713554987212276 0.8514745843989769 0.6649616368286445 0.8625659367007672 0.6355498721227621 0.8983995364450127 0.6304347826086957 0.9239949648337595 0.612531969309463 0.9197290601023017 0.5038363171355499 0.909490888746803 0.3887468030690537 0.7055806425831201 0.3618925831202046 0.5110553868286445 0.3388746803069054 0.3813718829923273 0.31841432225063937 0.29349424552429665 0.3248081841432225 +3 0.2329183983375959 0.35421994884910485 0.23206521739130434 0.39769820971867004 0.2576606457800511 0.39641943734015345 0.25680746483375955 0.3439897698209718 diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/classes.txt b/tests/data/test_import_yolo_seg_data_unif_dims/classes.txt new file mode 100644 index 00000000..979491c7 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/classes.txt @@ -0,0 +1,4 @@ +closed_door +opened_door +bus +number diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/images/img_1.jpg b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_1.jpg new file mode 100644 index 00000000..b44e1108 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_1.jpg differ diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/images/img_2.jpg b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_2.jpg new file mode 100644 index 00000000..615e9bb4 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_2.jpg differ diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/images/img_3.jpg b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_3.jpg new file mode 100644 index 00000000..bfb89144 Binary files /dev/null and b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_3.jpg differ diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/images/img_4.jpg b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_4.jpg new file mode 100644 index 00000000..dad4d95e Binary files /dev/null and b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_4.jpg differ diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/images/img_5.jpg b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_5.jpg new file mode 100644 index 00000000..5e62dd7a Binary files /dev/null and b/tests/data/test_import_yolo_seg_data_unif_dims/images/img_5.jpg differ diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_1.txt b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_1.txt new file mode 100644 index 00000000..c2cc26c2 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_1.txt @@ -0,0 +1,4 @@ +3 0.2628992628992629 0.11152351577883492 0.26044226044226043 0.229419803887889 0.31613431613431614 0.22304703155766983 0.32432432432432434 0.10993032269628014 +0 0.3882063882063882 0.207115100732122 0.49221949221949224 0.2166742592274507 0.49467649467649466 0.8491719130017004 0.3906633906633907 0.8826289677353507 +0 0.7526617526617527 0.23101299697044378 0.8214578214578213 0.24057215546577246 0.8255528255528255 0.7519871349658583 0.7633087633087634 0.7711054519565158 +2 0.062244062244062245 0.09081200570562271 0.029484029484029485 0.42697574612468225 0.025389025389025387 0.6595819361776808 0.03767403767403767 0.865103843827248 0.3734643734643734 0.9065268639736724 0.502047502047502 0.8778493884876863 0.5217035217035217 0.9192724086341107 0.552006552006552 0.9033404778085629 0.5765765765765766 0.8491719130017004 0.8476658476658475 0.7615462934611871 0.8558558558558559 0.7997829274425018 0.8738738738738738 0.8029693136076115 0.8853398853398854 0.747207555718194 0.941031941031941 0.732868817975201 0.9737919737919738 0.6962253770764408 0.9656019656019655 0.17047165983336196 0.7297297297297297 0.12586225352182798 0.4832104832104832 0.08603242645795837 0.27682227682227684 0.05576175788941746 0.1457821457821458 0.06691410946730095 diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_2.txt b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_2.txt new file mode 100644 index 00000000..87d6b18c --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_2.txt @@ -0,0 +1,4 @@ +3 0.6855036855036855 0.7774782242867349 0.6781326781326782 0.8969677054783438 0.7387387387387387 0.8937813193132341 0.7420147420147419 0.7806646104518444 +0 0.5094185094185094 0.15294653592525934 0.6076986076986077 0.12267586735671841 0.6109746109746109 0.7663258727088514 0.5135135135135135 0.7615462934611871 +0 0.17362817362817362 0.24216534854832727 0.24078624078624078 0.2278266108053342 0.24488124488124488 0.7456143626356392 0.18345618345618345 0.747207555718194 +2 0.029484029484029485 0.3027066856854091 0.0647010647010647 0.27402921019942295 0.11711711711711711 0.25331770012621074 0.12612612612612611 0.2087082938146768 0.14742014742014742 0.20392871456701245 0.1588861588861589 0.2389789623832177 0.4258804258804259 0.1545397290078141 0.457002457002457 0.09718477803584186 0.48566748566748574 0.08921881262306794 0.5085995085995086 0.12745544660438277 0.592956592956593 0.09877797111839665 0.6936936936936937 0.1051507434486158 0.9582309582309583 0.1338282189346019 0.9688779688779688 0.1545397290078141 0.9762489762489763 0.4253825530421275 0.9606879606879608 0.769512258873961 0.9418509418509419 0.9144928293864464 0.8026208026208026 0.9415771117898777 0.6281736281736282 0.9352043394596585 0.45782145782145783 0.9065268639736724 0.28746928746928746 0.8794425815702411 0.036036036036036036 0.8364263683412619 0.031122031122031123 0.5655835443069486 diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_3.txt b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_3.txt new file mode 100644 index 00000000..2cb3c60c --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_3.txt @@ -0,0 +1,4 @@ +3 0.26371826371826373 0.11311670886138972 0.26044226044226043 0.22304703155766983 0.3185913185913186 0.22623341772277944 0.3226863226863227 0.11152351577883492 +0 0.3898443898443899 0.21348787306234113 0.4914004914004914 0.22145383847511507 0.49385749385749383 0.8475787199191455 0.39230139230139227 0.8826289677353507 +0 0.7567567567567568 0.24216534854832727 0.823914823914824 0.24853812087854638 0.8255528255528255 0.7488007488007488 0.7592137592137592 0.769512258873961 +2 0.06142506142506143 0.09081200570562271 0.028665028665028666 0.44290767695023014 0.029484029484029485 0.7519871349658583 0.03521703521703522 0.8698834230749124 0.343980343980344 0.9017472847260081 0.5118755118755118 0.8698834230749124 0.5331695331695332 0.9128996363038915 0.5626535626535627 0.9081200570562272 0.5798525798525799 0.8475787199191455 0.8452088452088452 0.7615462934611871 0.8607698607698607 0.7965965412773923 0.8755118755118755 0.7902237689471732 0.8886158886158886 0.747207555718194 0.9418509418509419 0.732868817975201 0.9746109746109746 0.6978185701589956 0.9705159705159704 0.4540600285281136 0.9656019656019655 0.16728527366825235 0.7575757575757575 0.1338282189346019 0.538083538083538 0.09399839187073229 0.3570843570843571 0.06532091638474617 0.20638820638820637 0.0525753717243079 diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_4.txt b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_4.txt new file mode 100644 index 00000000..73b9a2ae --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_4.txt @@ -0,0 +1,4 @@ +3 0.26453726453726456 0.1147099019439445 0.26453726453726456 0.21986064539256028 0.3185913185913186 0.22304703155766983 0.32186732186732187 0.11152351577883492 +0 0.3841113841113841 0.2389789623832177 0.4873054873054873 0.24057215546577246 0.49385749385749383 0.8539514922493645 0.3906633906633907 0.8794425815702411 +0 0.7575757575757575 0.2580972793738751 0.8255528255528255 0.2676564378692038 0.8247338247338247 0.7583599072960774 0.7583947583947583 0.7774782242867349 +2 0.06142506142506143 0.08921881262306794 0.031122031122031123 0.4126370083816892 0.027027027027027025 0.6850730254985574 0.03521703521703522 0.8571378784144741 0.33415233415233414 0.8985608985608985 0.5094185094185094 0.8555446853319194 0.5307125307125307 0.9113064432213368 0.5659295659295659 0.8953745123957888 0.5904995904995906 0.8364263683412619 0.8271908271908273 0.7711054519565158 0.8517608517608518 0.820494437515714 0.8845208845208845 0.8125284721029402 0.9156429156429157 0.7312756248926462 0.9746109746109746 0.6930389909113314 0.963963963963964 0.16887846675080717 0.7616707616707616 0.12745544660438277 0.5577395577395577 0.08921881262306794 0.33824733824733827 0.05894814405452703 0.19328419328419325 0.04779579247664354 diff --git a/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_5.txt b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_5.txt new file mode 100644 index 00000000..e0233ba5 --- /dev/null +++ b/tests/data/test_import_yolo_seg_data_unif_dims/labels/img_5.txt @@ -0,0 +1,4 @@ +3 0.2620802620802621 0.10993032269628014 0.26044226044226043 0.21986064539256028 0.31613431613431614 0.21986064539256028 0.3226863226863227 0.10993032269628014 +0 0.3824733824733825 0.2087082938146768 0.48812448812448817 0.22145383847511507 0.4954954954954955 0.850765106084255 0.3939393939393939 0.8858153539004603 +0 0.7575757575757575 0.23101299697044378 0.8214578214578213 0.24057215546577246 0.8263718263718264 0.7599531003786324 0.7608517608517609 0.7806646104518444 +2 0.06633906633906633 0.08603242645795837 0.03194103194103194 0.3536888643271622 0.027846027846027844 0.6548023569300164 0.036036036036036036 0.8666970369098028 0.3841113841113841 0.9001540916434533 0.5135135135135135 0.8698834230749124 0.5323505323505323 0.9113064432213368 0.5601965601965602 0.9065268639736724 0.5864045864045864 0.8412059475889264 0.8452088452088452 0.7647326796262967 0.8607698607698607 0.8013761205250567 0.8787878787878788 0.7902237689471732 0.8869778869778869 0.7456143626356392 0.9393939393939393 0.732868817975201 0.9737919737919738 0.694632183993886 0.9672399672399672 0.1656920805856976 0.7002457002457002 0.11789628810905406 0.3685503685503686 0.06532091638474617 0.1850941850941851 0.05098217864175311