I am augmenting my image data-set which also contains key-points. For this reason I am using imgaug
library. Following is the augmentation code:
kps = KeypointsOnImage(__keypoints, shape=_image.shape)
seq = iaa.Sequential([
iaa.Affine(
scale={"x": (0.8, 1.2), "y": (0.8, 1.2)}, # scale images to 80-120% of their size, individually per axis
translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)}, # translate by -20 to +20 percent (per axis)
rotate=(-90, 90), # rotate by -45 to +45 degrees
order=[0, 1], # use nearest neighbour or bilinear interpolation (fast)
cval=(0, 255),
),
iaa.Fliplr(0.5),
], random_order=True)
# Augment keypoints and images.
image_aug, kps_aug = seq(image = _image, keypoints=kps)
But while reviewing the augmented images I found following problems:
But the weird thing is that the same code when I run it on my PC it runs completely okay. But when I run it on Google-Colab it creates these unwanted outputs. Why this is happening?
I found it was a version problem. In Colab the library imgaug
comes with a version 0.2.9
but this version produces these undesired outputs. So I uninstalled this existing version and installed the version 0.4.0
. Although while installation it showed the following error:
ERROR: albumentations 0.1.12 has requirement imgaug<0.2.7,>=0.2.5, but you'll have imgaug 0.4.0 which is incompatible.
But I ignored it and for me it worked fine. Following is the code to uninstall the existing version and to install the desired one:
!pip uninstall imgaug
!pip install imgaug==0.4.0
I installed the version 0.4.0
because I was working with this version on my local PC as well and it worked for me with no problem.