Albumentationsの基本トピック
Albumentationsの概要とインストール
Albumentationsは画像のデータ拡張(Data Augmentation)を行うにあたって用いられる高速かつフレキシブルなライブラリです。下記のコマンドを実行することによってPyPIからインストールすることが可能です。
$ pip install -U albumentations
pip install
のオプションでつけた-U
はライブラリがインストール済みだった場合に最新版にアップデートするオプションです。
Albumentationsのサンプルコードの実行
import random
import cv2
from matplotlib import pyplot as plt
import albumentations as A
image = cv2.imread('images/2007_000256.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
transform = A.HorizontalFlip(p=0.5)
random.seed(7)
augmented_image = transform(image=image)['image']
plt.imsave("results/output1.png", augmented_image)