如何将带有亮度的数据增强添加到图像分类框架中?
我正在使用 pytorch 进行图像分类,使用 github。 我需要在训练模型之前添加数据增强, 我选择了蛋白处理来做到这一点。 这是我添加白蛋白时的代码:
data_transform = {
"train": A.Compose([
A.RandomResizedCrop(224,224),
A.HorizontalFlip(p=0.5),
A.RandomGamma(gamma_limit=(80, 120), eps=None, always_apply=False, p=0.5),
A.RandomBrightnessContrast (p=0.5),
A.CLAHE(clip_limit=4.0, tile_grid_size=(8, 8), always_apply=False, p=0.5),
A.ShiftScaleRotate(shift_limit=0.05, scale_limit=0.05, rotate_limit=15, p=0.5),
A.RGBShift(r_shift_limit=15, g_shift_limit=15, b_shift_limit=15, p=0.5),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2(),]),
"val": A.Compose([
A.Resize(256,256),
A.CenterCrop(224,224),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2()])}
我收到此错误:
KeyError:在 DataLoader 工作进程 0 中捕获 KeyError。
KeyError:“您必须将数据作为命名参数传递给增强,例如:aug(image=image)”
I am using pytorch for image classification using this code from github.
I need to add data augmentation before training my model,
I chose albumentation to do this.
here is my code when I add albumentation:
data_transform = {
"train": A.Compose([
A.RandomResizedCrop(224,224),
A.HorizontalFlip(p=0.5),
A.RandomGamma(gamma_limit=(80, 120), eps=None, always_apply=False, p=0.5),
A.RandomBrightnessContrast (p=0.5),
A.CLAHE(clip_limit=4.0, tile_grid_size=(8, 8), always_apply=False, p=0.5),
A.ShiftScaleRotate(shift_limit=0.05, scale_limit=0.05, rotate_limit=15, p=0.5),
A.RGBShift(r_shift_limit=15, g_shift_limit=15, b_shift_limit=15, p=0.5),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2(),]),
"val": A.Compose([
A.Resize(256,256),
A.CenterCrop(224,224),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2()])}
I got this error:
KeyError: Caught KeyError in DataLoader worker process 0.
KeyError: 'You have to pass data to augmentations as named arguments, for example: aug(image=image)'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此 Albumentations 函数采用位置参数“image”并返回一个字典。这是使用它的示例:
This Albumentations function takes a positional argument 'image' and returns a dictionnary. This is a sample to use it :
您可以通过编写如下所示的课程来完成您想做的事情:
You can do what you want with writing a class like below:
我正确使用你的建议吗?
我有好图像和坏图像(水下图像)的数据集
model_weight_path = "./resnet34-pre.pth"
Am I using your suggestion correctly?
I have dataset of good and bad images (underwater images)
model_weight_path = "./resnet34-pre.pth"