【问题标题】:In Colab doing image data augmentation with "imgaug" is not working as intended在 Colab 中使用“imgaug”进行图像数据增强未按预期工作
【发布时间】:2020-06-25 17:13:09
【问题描述】:

我正在扩充我的图像数据集,其中还包含关键点。出于这个原因,我正在使用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)

但在查看增强图像时,我发现了以下问题:

  • 有些图像没有任何关键点。
  • 在一些增强图像中,关键点超出了图像之外,尽管我一直在检查以阻止将这些增强输出保存在关键点不在图像内部的位置。

但奇怪的是,当我在我的 PC 上运行相同的代码时,它运行完全正常。但是当我在 Google-Colab 上运行它时,它会创建这些不需要的输出。为什么会这样?

【问题讨论】:

    标签: computer-vision google-colaboratory object-detection data-augmentation keypoint


    【解决方案1】:

    我发现是版本问题。在 Colab 中,库 imgaug 带有一个版本 0.2.9,但这个版本会产生这些不想要的输出。所以我卸载了这个现有版本并安装了版本0.4.0。虽然在安装时显示以下错误:

    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.

    但我忽略了它,对我来说效果很好。以下是卸载现有版本并安装所需版本的代码:

    !pip uninstall imgaug
    !pip install imgaug==0.4.0
    

    我安装了 0.4.0 版本,因为我也在本地 PC 上使用此版本,它对我来说没有问题。

    【讨论】:

      【解决方案2】:

      Colab 附带 imgaug 版本 0.2.9,但此版本不符合专辑要求。我遇到了同样的问题,使用这个命令来纠正错误:

      !pip uninstall imgaug && pip uninstall albumentations && pip install git+https://github.com/aleju/imgaug.git
      

      【讨论】:

        猜你喜欢
        • 2022-01-15
        • 2021-12-16
        • 2017-03-22
        • 2020-01-15
        • 2019-10-24
        • 2019-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多