ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.64k stars 16.32k forks source link

Regarding the application establishment of preprocessing functions #13305

Open K011-17 opened 1 month ago

K011-17 commented 1 month ago

Search before asking

Question

YOLOv5 has various preprocessing functions, such as the Albumations library, mosaic, mixup, random_perspective, etc. If you look at the hyp file, you will see the parameters for each preprocessing function as shown below.

lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
lrf: 0.01 # final OneCycleLR learning rate (lr0 * lrf)
momentum: 0.937 # SGD momentum/Adam beta1
weight_decay: 0.0005 # optimizer weight decay 5e-4
warmup_epochs: 3.0 # warmup epochs (fractions ok)
warmup_momentum: 0.8 # warmup initial momentum
warmup_bias_lr: 0.1 # warmup initial bias lr
box: 0.05 # box loss gain
cls: 0.5 # cls loss gain
cls_pw: 1.0 # cls BCELoss positive_weight
obj: 1.0 # obj loss gain (scale with pixels)
obj_pw: 1.0 # obj BCELoss positive_weight
iou_t: 0.20 # IoU training threshold
anchor_t: 4.0 # anchor-multiple threshold
# anchors: 3  # anchors per output layer (0 to ignore)
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
degrees: 0.0 # image rotation (+/- deg)
translate: 0.1 # image translation (+/- fraction)
scale: 0.5 # image scale (+/- gain)
shear: 0.0 # image shear (+/- deg)
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001
flipud: 0.0 # image flip up-down (probability)
fliplr: 0.5 # image flip left-right (probability)
mosaic: 1.0 # image mosaic (probability)
mixup: 0.0 # image mixup (probability)
copy_paste: 0.0 # segment copy-paste (probability)

I think this represents the parameters of each preprocessing. But are preprocessing processes themselves applied definite? For example, are random_perspective and mosaic applied 100% to all images in each epoch? Or is there some probability of application? I would be grateful for your reply. Thanks in advance.

Additional

No response

glenn-jocher commented 1 month ago

@K011-17 preprocessing functions like random_perspective and mosaic in YOLOv5 are applied based on the probabilities specified in the hyperparameters file. For example, if mosaic is set to 1.0, it will be applied to all images, while a lower value indicates a reduced probability. You can adjust these probabilities to control the application frequency. For more details, refer to the YOLOv5 documentation.