Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Update example.py #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ def load_dataset(path):
width = int(tree.findtext("./size/width"))

for obj in tree.iter("object"):
xmin = int(obj.findtext("bndbox/xmin")) / width
ymin = int(obj.findtext("bndbox/ymin")) / height
xmax = int(obj.findtext("bndbox/xmax")) / width
ymax = int(obj.findtext("bndbox/ymax")) / height
xmin = int(obj.findtext("bndbox/xmin"))*1.0 / width
ymin = int(obj.findtext("bndbox/ymin"))*1.0 / height
xmax = int(obj.findtext("bndbox/xmax"))*1.0 / width
ymax = int(obj.findtext("bndbox/ymax"))*1.0 / height
if xmin==xmax or ymin==ymax:
print("you need to check {}".format(xml_file))
continue

dataset.append([xmax - xmin, ymax - ymin])

Expand All @@ -33,4 +36,4 @@ def load_dataset(path):
print("Boxes:\n {}".format(out))

ratios = np.around(out[:, 0] / out[:, 1], decimals=2).tolist()
print("Ratios:\n {}".format(sorted(ratios)))
print("Ratios:\n {}".format(sorted(ratios)))