From a6637a0ca6eda2293ab407ba183a7b1da2147950 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Verma Date: Tue, 27 Apr 2021 23:34:32 +0530 Subject: [PATCH] image filename issue resolved annotation from CVAT tool gives full path including the image folder name too. In that case, the code crashes as no file is found at that path. the split fix would just take the image name and append with path. --- voc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/voc.py b/voc.py index f51e5fd4a..d335c84c2 100644 --- a/voc.py +++ b/voc.py @@ -24,7 +24,9 @@ def parse_voc_annotation(ann_dir, img_dir, cache_name, labels=[]): for elem in tree.iter(): if 'filename' in elem.tag: - img['filename'] = img_dir + elem.text + # split will just take image name + # to avoid full path annotation errors + img['filename'] = img_dir + elem.text.split('/')[-1] if 'width' in elem.tag: img['width'] = int(elem.text) if 'height' in elem.tag: @@ -64,4 +66,4 @@ def parse_voc_annotation(ann_dir, img_dir, cache_name, labels=[]): with open(cache_name, 'wb') as handle: pickle.dump(cache, handle, protocol=pickle.HIGHEST_PROTOCOL) - return all_insts, seen_labels \ No newline at end of file + return all_insts, seen_labels