duanzhiihao / RAPiD

RAPiD: Rotation-Aware People Detection in Overhead Fisheye Images (CVPR 2020 Workshops)
http://vip.bu.edu/rapid/
Other
212 stars 63 forks source link

AttributeError: 'Detector' object has no attribute 'input_size' #12

Open nemtiax opened 4 years ago

nemtiax commented 4 years ago

I'm getting this error when training on COCO gets to the first evaluation step:

Traceback (most recent call last):
  File "train.py", line 229, in <module>
    dts = model_eval.detect_imgSeq(val_img_dir, input_size=target_size)
  File "/home/ubuntu/RAPiD_clean/RAPiD/api.py", line 90, in detect_imgSeq
    dts = self._detect_iter(iter(ims), **kwargs)
  File "/home/ubuntu/RAPiD_clean/RAPiD/api.py", line 97, in _detect_iter
    detections = self._predict_pil(pil_img=pil_frame, **kwargs)
  File "/home/ubuntu/RAPiD_clean/RAPiD/api.py", line 115, in _predict_pil
    input_size = kwargs.get('input_size', self.input_size)
AttributeError: 'Detector' object has no attribute 'input_size'

I think the reason this happens is that when a Detector is initialized for evaluation, it gets passed a model:

https://github.com/duanzhiihao/RAPiD/blob/c6fabcf5527bf0fca64a2d3b197d1c2822f22fb5/train.py#L226

If we look at Detector's init method, it sets self.input_size and self.conf_thres on lines 43-44, but if you pass a model, it will return on line 27, so input_size and conf_thres are never initialized.

Moving the initialization of input_size and conf_thres to the top of the init method resolved the issue for me, but I'm not sure if that's really the root cause, or if I'm just patching over some other problem (like maybe these are intended to be set elsewhere, and that's not working).

duanzhiihao commented 4 years ago

I think this problem shouldn't happen given that you specify the input_size=target_size when calling detect_imgSeq. Could you check if your target_size is None? https://github.com/duanzhiihao/RAPiD/blob/c6fabcf5527bf0fca64a2d3b197d1c2822f22fb5/train.py#L227

Moving the initialization of input_size and conf_thres to the top of the init method resolved the issue for me, but I'm not sure if that's really the root cause, or if I'm just patching over some other problem (like maybe these are intended to be set elsewhere, and that's not working).

This should work fine and cause no other problems.

nemtiax commented 4 years ago

I think my target_size is being set here:

https://github.com/duanzhiihao/RAPiD/blob/c6fabcf5527bf0fca64a2d3b197d1c2822f22fb5/train.py#L41

Which should propagate down to the call to detect_imgSeq. I'll add some debugging outputs and verify whether it's actually getting there, though.

duanzhiihao commented 4 years ago

It turns out that there is a bug in the api.py. I fixed it and it should work now. Could you try again and tell me if your problem resolved?