Closed VolkovAK closed 3 years ago
Answers are the same again! So I suppose that darknet internally resize image to CFG-size.
So now question itself - can I feed different image sizes to Darknet in python without having different instances of networks with different cfgs?
Darknet (the command-line version and the C API) will always resize the images to match the network size. And the stretching/resizing of the images does not care about aspect ratio, it will distort the image if necessary so it matches the network size.
I'm not familiar with the python interface, but if the python interface uses the same C API (and I believe it does) then your images will always be stretched to match the network.
You may also find this to be somewhat useful: https://www.ccoderun.ca/programming/2020-09-25_Darknet_FAQ/#square_network
@stephanecharette Thanks for answer!
I was too lazy to build OpenCV with CUDA support, so hopefully my GPU was able to fit in memory as much YOLO instances as I wanted.
Hello, Alexey, firstly I want to thank you for this awesome repository!
Yolov4 works perfectly via both OpenCV and Darknet python bindings. But I have found some bug probably: Python version of darknet can take images of different sizes, but in fact it's resizing to width and height specified in cfg-file. I discovered it when compared output with OpenCV. OpenCV DNN version of yolov4 do not resize image to cfg's sizes.
Take a look at this example:
Firstly, create the networks. Size in cfg is default, 608x608 for both Darknet and OpenCV
Then create input images
And now run models (postprocessing was written by me, it's correct 99.999%):
Let's see the results:
They are the same. Good.
Now, we change "size" variable:
And rerun just prediction, networks are the same:
Now they are not equal. And now, let's change size in CFG for darknet model to
Then rebuild rerun whole script with image size = (608,320) and see output:
Answers are the same again! So I suppose that darknet internally resize image to CFG-size.
So now question itself - can I feed different image sizes to Darknet in python without having different instances of networks with different cfgs?
Thanks in advance!