AlexeyAB / darknet

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

integrating maxpool layer in pytorch #2580

Open 123alaa opened 5 years ago

123alaa commented 5 years ago

Hi @AlexeyAB, I trained a model using this cfg (the same arch as yolov3-spp) yolov3-spp-320.log

and i try to test it using pytorch project based on this project: https://github.com/ayooshkathuria/pytorch-yolo-v3

Please take a look on darknet.py, I tried to integrate the max pool layer to this implementation, but i did not know which parameters you use (i search in your project).

How can i call your maxpool from torch.nn , with which param?

I tried this: nn.MaxPool2d(kernel_size, stride = stride, padding = (kernel_size-1)//2)

I see in your implementation that the padding in kernel_size -1 but it is not good.

Thnaks

AlexeyAB commented 5 years ago

@123alaa Hi,

I tried this: nn.MaxPool2d(kernel_size, stride = stride, padding = (kernel_size-1)//2)

Yes, it seems you should use this. Does it work?


There is used padding="SAME" in the Yolov3-spp: https://github.com/opencv/opencv/pull/9705/files#diff-fedccfdab4befb41d5ba901df318b1d2R197

123alaa commented 5 years ago

Yes, it works. I have an additional question: In each batch you do multi scaling right? Are you also resize the anchors in same way?

Because in the training resized images to 320*320, and the best anchors were the anchors of coco, although on their anchors is (373,326) that is bigger the my image, how it is work?

Best

AlexeyAB commented 5 years ago

No I don't resize anchors. May be it make sense to get higher accuracy.

although on their anchors is (373,326) that is bigger the my image, how it is work?

It isn't a big problem, receptive field of final activation doesn't depend on object size, so in general the object size (and anchor) may be any value.

123alaa commented 5 years ago

@AlexeyAB , I don't understood, darknet got absolute anchors like this: 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326

Are you make them relative to the image size?

AlexeyAB commented 5 years ago

@123alaa No. Anchors are the sizes of objects on images that are resized to the network size. So most likely they need to be resized during network resizing during training.