WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

How to enable autoanchor feature in yolor_p6? #165

Open 1chimaruGin opened 2 years ago

1chimaruGin commented 2 years ago

Thanks for sharing the amazing work.

I have a question. When I uncomment this line of code, this error occur.

if not opt.noautoanchor:
    check_anchors(dataset, model=model, thr=hyp['anchor_t'], imgsz=imgsz)

The error is:

Analyzing anchors... Traceback (most recent call last):
  File "train.py", line 538, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 210, in train
    check_anchors(dataset, model=model, thr=hyp['anchor_t'], imgsz=imgsz)
  File "/home/enma-v2/Desktop/DEEPLEARNING/pytorch/yolor/utils/autoanchor.py", line 25, in check_anchors
    m = model.module.model[-1] if hasattr(model, 'module') else model.model[-1]  # Detect()
  File "/home/enma-v2/anaconda3/envs/cuda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1131, in __getattr__
    type(self).__name__, name))
AttributeError: 'Darknet' object has no attribute 'model'

I search the Darknet model, but there no module and model in Darknet. How can I fix this?

r-judeh commented 2 years ago

Hi, I am having the same problem, did you figure it out?

SanKumSan commented 1 year ago

Same here, any inputs are welcome.