avikus-ai / detect_train

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

Yolov5 data augmentation #13

Closed dongwooshimssss closed 1 year ago

dongwooshimssss commented 1 year ago

Data Augmentation 부분 추가하였습니다. dataloaders.py 안에서 image가 load된 후 augmentations.py에 있는 함수들로 진행됩니다. hyperparameter 설정하실 수 있는 yaml파일을 hyp.scratch-low-avikus.yaml 이름으로 추가하였습니다.

hyperparameter로 추가한 항목은 다음과 같습니다.

이상입니다.

현재 copy and paste는 보수 작업 중에 있으며, 팀원분들 의견주시면 그에 맞춰 수정작업 진행하겠습니다. 감사합니다.

YoungjaeDev commented 1 year ago

@dongwooshimssss cap는 yaml에서 copyandpaste 0.0 아니면 무조건 1.0으로 해야할까요?

dongwooshimssss commented 1 year ago

@youngjae-avikus cap를 mosaic와 함께 적용하고 싶으시면 mosaic에 확률을 주시고, capmosaic에 True로 주신 후 targetclass, objscale, tarobjnum을 설정해주시면 되겠습니다.

mosaic를 적용하지 않고 cap만 적용하려면 mosaic를 0.0 주시고, capmosaic를 False 주신 후 copyandpaste에 확률 값을 주시면 되겠습니다.

예시 hyperparameter)

  1. cap & mosaic
    • mosaic: 1.0
    • capmosaic: True
    • targetclass: 0
    • objscale: 10000
    • tarobjnum: 5
    • copyandpaste: 0.0
  2. cap만 적용
    • mosaic: 0.0
    • capmosaic: False
    • targetclass: 0
    • objscale: 10000
    • tarobjnum: 5
    • copyandpaste: 1.0
  3. mosaic만 적용
    • mosaic: 1.0
    • capmosaic: False
    • copyandpaste: 0.0
YoungjaeDev commented 1 year ago

@dongwooshimssss

# YOLOv5  by Ultralytics, GPL-3.0 license
# Hyperparameters for low-augmentation COCO training from scratch
# python train.py --batch 64 --cfg yolov5n6.yaml --weights '' --data coco.yaml --img 640 --epochs 300 --linear
# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials

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: 0.0  # image mosaic (probability)
mixup: 0.0  # image mixup (probability)
copy_paste: 0.0  # segment copy-paste (probability)

####################################################
# added hyperparameters
# radnom crop while loading image -> True or False
randcrop: False

# cutout 
cutout: 0.0 # apply cutout augmentation

# cutmix
cutmix: 0.0 # apply cutmix augmentation

# augmix
augmix: 0.0 # apply augmix augmentation

# grid mask
gridmask: 0.0 # apply grid mask augmentation
gridnum: 7 # the number of grids in image
gridmode: 1 # 0: grid, 1: inverted, 2: Checked pattern 

# hide & seek
hideseek: 0.0 # apply hide & seek augmentation -> probability per grid, p = 0.25 is recommended
has_grid_s: [64] # list of grid size

# copy&paste with mosaic (mosaic after copy & paste)
capmosaic: False # copy & paste in mosaic -> True or False
targetclass: 0 # None or target class
objscale: 1000000 # object scale -> copy under this scale object
tarobjnum: 10 # the number of target object / it will search target object more than this value / if this value is 0 or small num, than it will search object and break as soon as it find the object.

# copy&paste without mosaic
copyandpaste: 1.0

# bilateral filtering
bilateral: 0.0

이렇게 하면 cap만 적용하는 것 맞습니까?

dongwooshimssss commented 1 year ago

@youngjae-avikus 네 맞습니다! 확률값 p만 copyandpaste에 주시면 됩니다.