AlexeyAB / darknet

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

Queries about Image resize from outside #1446

Open imsazzad opened 6 years ago

imsazzad commented 6 years ago

I have some images of various height and width which you implementation can easily handle, I know. it gave an excellent result on my dataset. Thank you/ :1st_place_medal: .But I want to resize the image before giving it to the Yolo as it takes huge memory( width- height: 2000 +,2000+). So my questions are :

  1. what is the best aspect ratio or image height, width size where Yolo can perform similarly. ?
  2. which library for image resizing would you recommend me that have less information loss?

Thanks in advance

AlexeyAB commented 6 years ago
  1. The best size of images that higher than 1.5 x width in cfg-file, and 1.5 x height in cfg-file. Where is 1.5 - a multiplier during data augmentation when random=1 in your cfg-file. Also you should follow the rule: https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

General rule - your training dataset should include such a set of relative sizes of objects that you want to detect:

train_network_width * train_obj_width / train_image_width ~= detection_network_width * detection_obj_width / detection_image_width

train_network_height * train_obj_height / train_image_height ~= detection_network_height * detection_obj_height / detection_image_height

  1. You can write your own code (in C, C++, Python) to convert your images by using OpenCV with CUBIC-interpolation:
    • C cvResize(src_image, dst_image, CV_INTER_CUBIC);
    • C++ cv::resize(src_image, dst_image, cv::Size(new_w, new_h), 0, 0, CV_INTER_CUBIC);
    • Python dst_image= cv2.resize(src_image, (new_w, new_h), interpolation=CV_INTER_CUBIC)