Skip to content

Commit

Permalink
skip empty and to relative coords
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Nov 29, 2021
1 parent 578428c commit acec9df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions doctr/datasets/icdar2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ def __init__(
for rect in rectangles
]

# Get the labels
labels = [lab.text for rect in rectangles for lab in rect if lab.text]

self.data.append((name.text, dict(boxes=np.asarray(_boxes, dtype=np_dtype), labels=labels)))
# filter images without boxes
if _boxes:
# Convert them to relative
w, h = int(resolution.attrib['x']), int(resolution.attrib['y'])
boxes = np.asarray(_boxes, dtype=np_dtype)
boxes[:, [0, 2]] /= w
boxes[:, [1, 3]] /= h

# Get the labels
labels = [lab.text for rect in rectangles for lab in rect if lab.text]

self.data.append((name.text, dict(boxes=boxes, labels=labels)))

self.root = tmp_root

Expand Down
2 changes: 1 addition & 1 deletion tests/pytorch/test_datasets_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_visiondataset():
['SVT', False, [512, 512], 249, False],
['SynthText', True, [512, 512], 27, True], # Actual set has 772875 samples
['SynthText', False, [512, 512], 3, False], # Actual set has 85875 samples
['ICDAR2003', True, [512, 512], 250, True],
['ICDAR2003', True, [512, 512], 246, True],
['ICDAR2003', False, [512, 512], 249, False],
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/tensorflow/test_datasets_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
['SVT', False, [512, 512], 249, False],
['SynthText', True, [512, 512], 27, True], # Actual set has 772875 samples
['SynthText', False, [512, 512], 3, False], # Actual set has 85875 samples
['ICDAR2003', True, [512, 512], 250, True],
['ICDAR2003', True, [512, 512], 246, True],
['ICDAR2003', False, [512, 512], 249, False],
],
)
Expand Down

0 comments on commit acec9df

Please sign in to comment.