Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] SVT dataset: clip box values and add shape and label check #955

Merged
merged 1 commit into from
Jun 24, 2022
Merged
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
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])))
felixdittrich92 marked this conversation as resolved.
Show resolved Hide resolved
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