YOLOP icon indicating copy to clipboard operation
YOLOP copied to clipboard

Anchor setup

Open ckcraig01 opened this issue 3 years ago • 3 comments

Dear Authors,

thanks for your great work. I have a basic question: https://github.com/hustvl/YOLOP/blob/a30c32c3ea17970e8daa94ee99e5803acdcf1a48/export_onnx.py#L44 I believe this is your default anchors, [3, 9, 5, 11, 4, 20], [7, 18, 6, 39, 12, 31], [19, 50, 38, 81, 68, 157] My question is why the anchors are vertical instead of horizontal (for horizontal vehicles) ? stride 8: [3, 9, 5, 11, 4, 20]: stride 16: [7, 18, 6, 39, 12, 31], stride 32: [19, 50, 38, 81, 68, 157] I think the order is [anchor1_w, anchor1_h, anchor2_w, anchor2_h, anchor3_w, anchor3_h] for each layer https://github.com/hustvl/YOLOP/blob/a30c32c3ea17970e8daa94ee99e5803acdcf1a48/lib/models/common2.py#L241

One reason I could think of is maybe the autoanchor makes 1280x720 -> 640x640 (not keeping aspect ratio), and thus make the anchors more vertical-like (but I have not yet look into the code) But the inference in YOLOP seem to be keeping aspect ratio.

Above is my question. Thanks again for the great work.

ckcraig01 avatar Sep 29 '21 15:09 ckcraig01

I could think of another reason is that maybe person class is used in autoanchor instead of vehicle class: I found yolov5 is with some horizontal anchors, too: https://github.com/ultralytics/yolov5/blob/master/models/yolov5s.yaml#L7

  • [10,13, 16,30, 33,23] # P3/8
  • [30,61, 62,45, 59,119] # P4/16
  • [116,90, 156,198, 373,326] # P5/32

Adding comment: the filtered shall be done in bdd.py already: https://github.com/hustvl/YOLOP/blob/bff896e34d1c6ed75ea40353184e2ea8058b8a93/lib/dataset/bdd.py#L40, so only car, truck, bus, train are remaind in the bbox db.

ckcraig01 avatar Sep 29 '21 15:09 ckcraig01

Dear Author:

I just found the bug, if you print out:

https://github.com/hustvl/YOLOP/blob/main/lib/utils/autoanchor.py#L87 " shapes = img_size * dataset.shapes / dataset.shapes.max()"

you will find the shapes is [360, 640], but you multiple it with w and h: in next line wh0 = labels[:, 3:5] * shapes this is to say, you shall make the shapes from [360,640] to [640,360].

Please confirm whether I am correct. Thank you

ckcraig01 avatar Sep 30 '21 02:09 ckcraig01

Sir, did you find any solution on this problem?

ilpapds avatar Feb 15 '23 14:02 ilpapds