lucasjinreal / yolov7_d2

🔥🔥🔥🔥 (Earlier YOLOv7 not official one) YOLO with Transformers and Instance Segmentation, with TensorRT acceleration! 🔥🔥🔥
GNU General Public License v3.0
3.13k stars 483 forks source link

modified: yolov7/data/detection_utils.py #187

Closed Hommoner closed 1 year ago

Hommoner commented 1 year ago

allow not using SHIFT_PIXELS by config cfg.INPUT.SHIFT.SHIFT_PIXELS=0 allow RandomFlip and achieve horizontal and vertical by config cfg.INPUT.RANDOM_FLIP = "horizontal,vertical"

lucasjinreal commented 1 year ago

@Hommoner thanks for contribution!

this feature sounds good for me, but we might still need some modify.

Could u please make 1 edit?

  1. Make all new add augmentation with a ENABLED machanism.

like for Shifts, if we don't want shifts in augmentation just disable it:

INPUT:
  SHIFTS:
    ENABLED: True
    SHIFT_PIXELS: 1.2
INPUT:
  SHIFTS:
    ENABLED: false
    SHIFT_PIXELS: 1.2

same as Random Flip, only append when users implicit defines ENABLED as True in config.

Hommoner commented 1 year ago

I agree with SHIFTS add ENABLED Flag is a good idea , but we should consider that flip parameters initial to cfg.INPUT.RANDOM_FLIP = "horizontal" in cfg = get_cfg() , where derived from detectron2.config import get_cfg. so even we change RANDOM_FLIP like this this

RANDOM_FLIP_HORIZONTAL: ENABLED: False RANDOM_FLIP_VERTICAL: ENABLED: False

after cfg initialized, user will still see the cfg paramter cfg.INPUT.RANDOM_FLIP = "horizontal"

lucasjinreal commented 1 year ago

@Hommoner thanks for the modify. It looks good to me.

It would be better if there is a PRO field under RNADOM_FLIP_HORIZONTAL, so that we can append new aug in datamapper like this:

T.RandomFlip(prob=cfg.INPU.RANDOM_FLIP_HORIZONTAL.PROB, horizontal=cfg.INPU.RANDOM_FLIP_HORIZONTAL.ENABLED, vertical=False),
Hommoner commented 1 year ago

done, please check