Original Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "LOAF/fisheye-eval/datasets/loaf.py", line 48, in getitem
img, target = self._transforms(img, target)
File "LOAF/fisheye-eval/datasets/transform_loaf.py", line 198, in call
image, target = t(image, target)
File "LOAF/fisheye-eval/datasets/transform_loaf.py", line 198, in call
image, target = t(image, target)
File "LOAF/fisheye-eval/datasets/transform_loaf.py", line 170, in call
return F.to_tensor(img), target
File "/opt/conda/lib/python3.8/site-packages/torchvision/transforms/functional.py", line 137, in to_tensor
raise TypeError(f"pic should be PIL Image or ndarray. Got {type(pic)}")
TypeError: pic should be PIL Image or ndarray. Got <class 'NoneType'>
保存结果
Traceback (most recent call last):
File "main.py", line 416, in
main(args)
File "main.py", line 322, in main
test_stats, coco_evaluator = evaluate(model, criterion, postprocessors,
File "/opt/conda/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "LOAF/fisheye-eval/engine.py", line 241, in evaluate
res_info = torch.cat((_res_bbox, _res_prob.unsqueeze(-1), _res_label.unsqueeze(-1)), 1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 300 but got size 100 for tensor number 1 in the list.
问题概述
你好,我这边试着训了几轮然后尝试做验证,结果发现有些问题
错误报告
无人图片
保存结果
原因分析
通过检查发现是由于LOAF数据集中有些图片本身就没有行人(如id:1164,0062_01065.jpg),遇到这些图时,
代码得到的标注是空的,所以在执行try中的stack语句会报错,从而被except接收返回
img=None, target=None
https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/datasets/loaf.py#L75-L86进一步
self.prepare
返回的都是None,在后续的执行预处理时报错 https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/datasets/loaf.py#L46-L48发现是模型输出的predboxes维度跟后处理后的维度不一致,如下面两处代码所示 https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/engine.py#L218-L226 https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/engine.py#L237-L240
outbbox
代表模型输出的结果,通过检查发现维度为(300,4);而后面两处_res_prob
和_res_label
来自后处理得到的结果,维度是(100,1),它们的维度不一致,无法拼接尝试修改
一开始尝试修改代码,使得遇到空图像时,target返回的内容里面子项的结果是空列表tensor
torch.stack
前加入判断,如果boxes
为空则直接用个空tensor代替,然后继续后续的操作boxes /= w
避免报错 https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/datasets/transform_loaf.py#L187但是这些修改完后也会在调用
HungarianMatcher
进行匹配时,调用torch.cdist
时因为tgt_bbox
是空列表tensor而报错 https://github.com/BUPT-PRIV/LOAF/blob/a5c435eb013f0729c64824477b62649f8325a5a7/fisheye-eval/models/dab_deformable_detr/matcher.py#L87-L88修改到这由于我对DAB_DETR不是很熟悉,不确定后续再修改下去是否会违背原本的意思
这里同样我对DAB_DETR不熟悉,不确定这里要怎么调整使得后处理前后的维度保持一致
期望
单纯跑eval只给了下面的结果