Hi,
I have been running this script in google colab.
First of all, thank you very much for this, super clear!
I have noticed a potential bug when running the trainer.evaluate
command.
The original is working fine however as soon I try to run it for a single record or with a batch size creating a single record batch (let’s say 9 since eval batch size default to 8) then it fails.
ValueError Traceback (most recent call last)
in <cell line: 0>()
----> 1 metrics2 = trainer.evaluate(eval_dataset=t_dataset, metric_key_prefix="eval")
4 frames
in collect_targets(self, targets, image_sizes)
33 # here we have "yolo" format (x_center, y_center, width, height) in relative coordinates 0..1
34 # and we need to convert it to "pascal" format (x_min, y_min, x_max, y_max) in absolute coordinates
---> 35 height, width = size
36 boxes = torch.tensor(target["boxes"])
37 boxes = center_to_corners_format(boxes)
ValueError: not enough values to unpack (expected 2, got 1)
If you want to recreate the error:
t_dataset = CPPE5Dataset(dataset["test"].select([1]), image_processor, transform=validation_transform)
metrics = trainer.evaluate(eval_dataset=t_dataset, metric_key_prefix="eval")
or
t_dataset = CPPE5Dataset(dataset["test"].select(list(range(2))), image_processor, transform=validation_transform)
metrics = trainer.evaluate(eval_dataset=t_dataset, metric_key_prefix="eval")
After diving a bit more in the error, realised that the model prediction seem to select only the first index for all the values in the label dictionary when the batch size is one. That is why the image_size only has tensor([480])
instead of tensor([480,480])
.
Hope you guys can help! Thank you