sovit-123 / fasterrcnn-pytorch-training-pipeline

PyTorch Faster R-CNN Object Detection on Custom Dataset
MIT License
206 stars 67 forks source link

RuntimeWarning: invalid value encountered in power img = np.power(img, gamma) #89

Open utility-aagrawal opened 1 year ago

utility-aagrawal commented 1 year ago

Hi,

I get the following error when I train with --use-train-aug: image

It stems from albumentaions' gamma correction method - Numpy can't handle a fractional power of a negative number (see this - https://github.com/numpy/numpy/issues/20186)

Note that I don't have negative pixel values. My input is in pascal_voc format and I think some zero pixel values are changing to very small negative values during normalization due to floating point error.

I was able to suppress this error by changing normalized pixel values to zero during gamma correction/transformation but would like to hear your suggestion on this. Added the following code block before np.power statement in albumentaions' gamma correction method:

img[img < 0] = 0

Thanks!

sovit-123 commented 1 year ago

It may be dataset specific. Kind of hard to say much here actually. In fact, this is the first time I am seeing this error. Still, will try to research more.