Skip to content

Commit

Permalink
Fix problem for XML files which additional tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalabka authored and sglvladi committed Jun 8, 2021
1 parent d789f03 commit 292865b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions docs/source/scripts/generate_tfrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,19 @@ def xml_to_csv(path):
for xml_file in glob.glob(path + '/*.xml'):
tree = ET.parse(xml_file)
root = tree.getroot()
filename = root.find('filename').text
width = int(root.find('size').find('width').text)
height = int(root.find('size').find('height').text)
for member in root.findall('object'):
value = (root.find('filename').text,
int(root.find('size')[0].text),
int(root.find('size')[1].text),
member[0].text,
int(member[4][0].text),
int(member[4][1].text),
int(member[4][2].text),
int(member[4][3].text)
bndbox = member.find('bndbox')
value = (filename,
width,
height,
member.find('name').text,
int(bndbox.find('xmin').text),
int(bndbox.find('ymin').text),
int(bndbox.find('xmax').text),
int(bndbox.find('ymax').text),
)
xml_list.append(value)
column_name = ['filename', 'width', 'height',
Expand Down

0 comments on commit 292865b

Please sign in to comment.