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??
Hello @yangjinghit, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook , 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:
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!
Most helpful comment
@MaxwellHogan
--image-weightssamples 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.