在 fastai v2 中我试图添加图像增强
所以
tfms = aug_transforms(do_flip = True,
flip_vert=True,
max_lighting=0.1,
)
data = ImageDataLoaders.from_df(df,bs=5,item_tfms=tfms,folder=path_to_data)
Run Code Online (Sandbox Code Playgroud)
这给出了输出
Could not do one pass in your dataloader, there is something wrong in it
当我这样做时
data.show_batch()
Run Code Online (Sandbox Code Playgroud)
它给
RuntimeError: "check_uniform_bounds" not implemented for 'Byte'
Run Code Online (Sandbox Code Playgroud)
如何解决
小智 9
I didn't try the do_flip transformation, but what worked for me was to apply them not as item_tfms but as batch_tfms:
item_tfms = [ Resize((200, 150), method='squish')]
batch_tfms = [Brightness(max_lighting = 0.3, p = 0.4),
Contrast(max_lighting = 0.6, p = 0.4),
Saturation(max_lighting = 0.75, p = 0.4)]
db = DataBlock(blocks = (ImageBlock, CategoryBlock),
get_items = get_image_files,
splitter = RandomSplitter(valid_pct=0.2, seed=42),
item_tfms=item_tfms,
batch_tfms=batch_tfms,
get_y = parent_label)
Run Code Online (Sandbox Code Playgroud)
You can then feed the DataBlock into a DataLoader like in the fastbook tutorial
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |