Skip to content

Commit c97587a

Browse files
Fix bboxes being overwritten before use in prepare_example (#50218)
Rename variable 'bboxes' to 'in_bboxes' in example to Fix `bboxes` being overwritten before use in `prepare_example` **Problem** In `prepare_example`, `objects["bbox"]` is assigned to `bboxes`, and a few lines later `bboxes, cats, areas, ids = [], [], [], []` rebinds the same name to an empty list. `zip(bboxes, categories)` then iterates over nothing, so every example is returned with an empty `bbox` list and the `filter(len(...) > 0)` step drops the whole dataset (train/validation sizes print as 0). **Check** After the change, `Train: <N>, Validation: <M>` prints non-zero sizes.
1 parent e03c353 commit c97587a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎docs/source/en/tasks/object_detection.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ categories to integer ids, compute areas, and filter out degenerate bounding box
8787
```py
8888
>>> def prepare_example(example, idx):
8989
... objects = example["objects"]
90-
... bboxes = objects["bbox"]
90+
... in_bboxes = objects["bbox"]
9191
... categories = objects["category"]
9292
... img_w, img_h = example["width"], example["height"]
9393
... bboxes, cats, areas, ids = [], [], [], []
94-
... for i, (bbox, cat) in enumerate(zip(bboxes, categories)):
94+
... for i, (bbox, cat) in enumerate(zip(in_bboxes, categories)):
9595
... x, y, w, h = bbox
9696
... if w <= 0 or h <= 0:
9797
... continue

0 commit comments

Comments
 (0)