Skip to content

Commit

Permalink
clip box values and add shape and label check
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Jun 17, 2022
1 parent 210ecc4 commit abac30c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doctr/datasets/svt.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def __init__(
if recognition_task:
crops = crop_bboxes_from_image(img_path=os.path.join(tmp_root, name.text), geoms=boxes)
for crop, label in zip(crops, labels):
self.data.append((crop, dict(labels=[label])))
if crop.shape[0] > 0 and crop.shape[1] > 0 and len(label) > 0:
self.data.append((crop, dict(labels=[label])))
else:
# Convert coordinates to relative
w, h = int(resolution.attrib['x']), int(resolution.attrib['y'])
Expand All @@ -104,7 +105,7 @@ def __init__(
boxes[:, [0, 2]] /= w
boxes[:, [1, 3]] /= h

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

self.root = tmp_root

Expand Down

0 comments on commit abac30c

Please sign in to comment.