Yolov5: img-weights

Created on 29 Oct 2020  路  7Comments  路  Source: ultralytics/yolov5

鉂擰uestion

parser.add_argument('--img-weights', action='store_true', help='use weighted image selection for training')
in order to make --iimg-weights work, what else I need to do?
dataset = LoadImagesAndLabels(path, imgsz, batch_size,
augment=augment, # augment images
hyp=hyp, # augmentation hyperparameters
rect=rect, # rectangular training
cache_images=cache,
single_cls=opt.single_cls,
stride=int(stride),
pad=pad),
should I add an extra param image_weights=True??

Additional context

question

Most helpful comment

@MaxwellHogan --image-weights samples images from the training set weighted by their inverse mAP from the previous epoch's testing (rather than sampling the images uniformly as in normal training). This will result in images with a high content of low-mAP objects being selected with higher likelihood during training.

This is not the same as the method in your link.

All 7 comments

Hello @yangjinghit, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@glenn-jocher

w = model.class_weights.cpu().numpy() * (1 - maps) ** 2 # class weights
image_weights = labels_to_image_weights(dataset.labels, nc=nc, class_weights=w)
dataset.indices = random.choices(range(dataset.n), weights=image_weights,
k=dataset.n) # rand weighted idx

I did not find anywhere show how to use dataset.indices in above codes

@yangjinghit to use image weighting you simply pass the argument during training:
python train.py --img-weights

@glenn-jocher Hey Bud, could you summarise what img-weights does?

is it similar to threshold-moving:
https://machinelearningmastery.com/threshold-moving-for-imbalanced-classification/

@MaxwellHogan --image-weights samples images from the training set weighted by their inverse mAP from the previous epoch's testing (rather than sampling the images uniformly as in normal training). This will result in images with a high content of low-mAP objects being selected with higher likelihood during training.

This is not the same as the method in your link.

@glenn-jocher thanks for the prompt feedback!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShreshthSaxena picture ShreshthSaxena  路  4Comments

nanometer34688 picture nanometer34688  路  3Comments

hktxt picture hktxt  路  3Comments

DucTaiVu picture DucTaiVu  路  3Comments

lisa676 picture lisa676  路  3Comments