From 7cb61546656ac1b09b2d20c540cd28bff33dcbe9 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 27 Sep 2020 15:20:27 +0800 Subject: [PATCH] Update psdxml2yolotxt.py --- psdxml2yolotxt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/psdxml2yolotxt.py b/psdxml2yolotxt.py index 4502a4a..d720c98 100644 --- a/psdxml2yolotxt.py +++ b/psdxml2yolotxt.py @@ -27,6 +27,7 @@ WITH_IMAGE = True REWRITE = True DRAW_LABEL = True +COPY_TXT_TO_IMG_FOLDER = True TRAIN_RATE = 0.8 CONER_ROI_SIZE = 21 @@ -127,7 +128,8 @@ def convert_annotation(xml_dir, img_dir): else: txt_val_list.write(imgfile + '\n') - out_file = open(txt_dir + "/" + fileInfor[0] + ".txt", 'w') + txt_path = txt_dir + "/" + fileInfor[0] + ".txt" + out_file = open(txt_path, 'w') dom = xml.dom.minidom.parse(xml_path) annotation = dom.documentElement @@ -173,6 +175,9 @@ def convert_annotation(xml_dir, img_dir): cv2.rectangle(img, (xtl, ytl), (xbr, ybr), (255, 0, 0)) out_file.close() + if COPY_TXT_TO_IMG_FOLDER: + dst_txt = os.path.join(img_dir, os.path.basename(txt_path)) + shutil.copyfile(txt_path, dst_txt) if DRAW_LABEL: draw_path = xml_dir + "_" + draw_folder if not os.path.exists(draw_path):