Skip to content

Commit

Permalink
Update psdxml2yolotxt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aimuch authored Sep 27, 2020
1 parent 1ebf5b0 commit 7cb6154
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion psdxml2yolotxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 7cb6154

Please sign in to comment.