我正在扩充我的图像数据集,其中也包含关键点。因此我正在使用imgaug
图书馆。以下是增强代码:
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)
但在查看增强图像时,我发现了以下问题:
- 有些图像没有任何关键点。
- 在某些增强图像中,关键点位于图像之外,尽管我不断检查以阻止将那些增强输出保存在关键点不在图像内部的位置。
但奇怪的是,当我在我的电脑上运行相同的代码时,它运行完全正常。但是当我在 Google-Colab 上运行它时,它会创建这些不需要的输出。为什么会发生这种情况?