データ変換 (更新が必要)¶
データ変換パイプラインの設計¶
一般的な慣例に従い、複数ワーカーによるデータ読み込みに `Dataset` と `DataLoader` を使用します。 `Dataset` は、モデルの順方向メソッドの引数に対応するデータ項目の辞書を返します。
データ変換パイプラインとデータセットは分離されています。通常、データセットはアノテーションの処理方法を定義し、データ変換パイプラインはデータ辞書を準備するためのすべての手順を定義します。パイプラインは、一連のデータ変換で構成されます。各操作は辞書を入力として受け取り、次の変換のために辞書を出力します。
以下の図に、典型的なパイプラインを示します。青いブロックはパイプライン操作です。パイプラインが進むにつれて、各演算子は結果辞書に新しいキー(緑色でマーク)を追加したり、既存のキー(オレンジ色でマーク)を更新したりできます。
Faster R-CNN のパイプライン例を以下に示します。
train_pipeline = [ # Training data processing pipeline
dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path
dict(
type='LoadAnnotations', # Second pipeline to load annotations for current image
with_bbox=True), # Whether to use bounding box, True for detection
dict(
type='Resize', # Pipeline that resize the images and their annotations
scale=(1333, 800), # The largest scale of image
keep_ratio=True # Whether to keep the ratio between height and width
),
dict(
type='RandomFlip', # Augmentation pipeline that flip the images and their annotations
prob=0.5), # The probability to flip
dict(type='PackDetInputs') # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples
]
test_pipeline = [ # Testing data processing pipeline
dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path
dict(type='Resize', scale=(1333, 800), keep_ratio=True), # Pipeline that resize the images
dict(
type='PackDetInputs', # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]