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

image and annotation resize #2314

Open barry41409 opened 5 years ago

barry41409 commented 5 years ago

hi everyone, I train yolo model now and have some question about model.

  1. Why the model can support any image size in training? (The cfg set the width and height, the image should same with cfg setting.)

  2. In training, Are the images resized to other size? for example,

    1510: 0.577589, 0.715066 avg loss, 0.001000 rate, 0.325438 seconds, 96640 images
    Resizing
    352 x 352 
    try to allocate workspace = 26215425 * sizeof(float),  CUDA allocate done! 
    Loaded: 0.121298 seconds
    Region Avg IOU: 0.562391, Class: 0.800683, Obj: 0.000304, No Obj: 0.000409, Avg Recall: 0.678571,  count: 56
    Region Avg IOU: 0.600623, Class: 0.831313, Obj: 0.000089, No Obj: 0.000503, Avg Recall: 0.722222,  count: 36
    Region Avg IOU: 0.643509, Class: 0.814504, Obj: 0.000031, No Obj: 0.000639, Avg Recall: 0.700000,  count: 30
    Region Avg IOU: 0.610090, Class: 0.885814, Obj: 0.000140, No Obj: 0.000464, Avg Recall: 0.761905,  count: 42
  3. Can I resize image by myself before training? (In darknet, resize image function in src/image.c. right?) How can I modify the original annotation to new annotation for resizing image? Do I refer any other code in darknet?

AlexeyAB commented 5 years ago

Hi,

  1. Any image will be resized to the network size automatically

  2. Yes.

  3. You shouldn't do it. Yolo uses relative coordinates in annotation-files that are don't depend on image size.

barry41409 commented 5 years ago

Thanks, @AlexeyAB .

The width and height in cfg set the input size for first layer. In traing, reizing image can help improve performance ?

The model cfg set the width and height 416. If a application scenario only produce fixed size image to model for inference ex : 512512 or 416416......, can I resize the testing data to the fixed size for testing?

For simulating the scenario, I want to resize VOC test data but I don't know how to modify the annotation. How can I modify the original annotation to new annotation for fixed size image?

AlexeyAB commented 5 years ago

In traing, reizing image can help improve performance ?

No.

can I resize the testing data to the fixed size for testing?

You can. But you shouldn't do it.

I want to resize VOC test data but I don't know how to modify the annotation.

Even if you resized images, you shouldn't change the annotations, because they will still be the same, because that are relative.

barry41409 commented 5 years ago

hi, @AlexeyAB

In traing, reizing image can help improve performance ?

No.

What problem will resizing image produce in training?

can I resize the testing data to the fixed size for testing?

You can. But you shouldn't do it.

Why shouldn't do it? I want to simulate the scenario. If I resize the test data, will it decrease the mAP? or do you have any other command for fixed size image in the scenario?