zgcr / SimpleAICV_pytorch_training_examples

SimpleAICV:pytorch training and testing examples.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

使用imagenet训练resnet50读取数据有问题,想请教您

Qingzhang1994 opened this issue · comments

image

image

image

我按照您的编程环境,在运行代码时出现了这个错误,希望你能解答一下

commented

你好,是否修改了训练dataset类的transform?
train_dataset = ILSVRC2012Dataset(
root_dir=ILSVRC2012_path,
set_name='train',
transform=transforms.Compose([
Opencv2PIL(),
TorchRandomResizedCrop(resize=input_image_size),
TorchRandomHorizontalFlip(prob=0.5),
TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
]))
这个dataset最开始读取是opencv读取的图片哈,所以最前面必须要用Opencv2PIL()转成PIL图片,才可以继续用下面的三个数据增强哈。

commented

请把完整的train_config.py文件和完整的ilsvrc2012dataset.py文件贴出来一下,看看改了什么东西,如果没改的话,不应该报错。

commented

这个红框没什么问题呀,dataset里image和label都是这样的键值对形式。你的collator函数没有用我写的函数?

commented

train_loader = DataLoader(config.train_dataset,
batch_size=batch_size,
shuffle=False,
pin_memory=False,
num_workers=num_workers,
collate_fn=config.train_collater,
sampler=train_sampler,
worker_init_fn=init_fn)
检查一下这个collate_fn是不是改了?还有ClassificationDataPrefetcher这个函数用的还是原来的吗?

我把问题以邮件的形式发您,感谢您的回复

commented

我把问题以邮件的形式发您,感谢您的回复

我看你在里面改了不少东西,请把所有修改之处完整的给出来,目前来看,我只有上面两个猜测。

commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented
commented