AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.64k stars 7.95k forks source link

about forward_yolo_layer #1541

Open yy18dlz opened 5 years ago

yy18dlz commented 5 years ago

Hi, i have a question.. for (b = 0; b < l.batch; ++b){ for(n = 0; n < l.n; ++n){ int index = entry_index(l, b, nl.wl.h, 0); activate_array(l.output + index, 2l.wl.h, LOGISTIC); // why only activate x and y? how about w and h index = entry_index(l, b, nl.wl.h, 4); activate_array(l.output + index, (1+l.classes)l.wl.h, LOGISTIC); } }

AlexeyAB commented 5 years ago

@zxh666 Hi,

Yes, only (x,y) is logistically activated (sigmoid). But (w,h) activated in such a way exp(Tw)*Anchors_w and exp(Th)*Anchor_h

https://github.com/AlexeyAB/darknet/blob/18d5e4f39c1441f2c21043ac3204b5cb279f8758/src/yolo_layer.c#L84-L92

    b.x = (Cx + Tx_logistic_activated) / layer_w;
    b.y = (Cy + Ty_logistic_activated) / layer_h;
    b.w = exp(Tw) * Pw   / layer_w;
    b.h = exp(Th) * Ph / layer_h;

https://pjreddie.com/media/files/papers/YOLOv3.pdf

45033576-98fd8a00-b05d-11e8-8693-a2057c31e07e