Skip to content

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

Open
@nemtiax

Description

@nemtiax

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:

RAPiD/train.py

Line 226 in c6fabcf

model_eval = api.Detector(conf_thres=0.005, model=model)

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions