Open wangshouxu opened 2 years ago
请告知我您所使用的torchvision版本。在我所使用的torchvision 0.2.2中,ColorJitter
类的对象调用get_params
函数(见第43至第44行)的返回值是torchvision.transforms.transforms.Compose
类型的,故程序运行时不会报告此错误。
Please tell me the version of torchvision in your environment. In torchvision 0.2.2, which is the version in my environment, the type of the returning value of a ColorJitter
object when calling get_params
(In line 43~44) is torchvision.transforms.transforms.Compose
. Therefore, there's no such error reported while running the code.
我用的torchvision版本是0.10.0
会与版本问题有关么
color_transform的类型是 ![Uploading 20220105_152641.jpg…]()
您好,确实是跟版本有关系的,这是0.10.0的get_params ![Uploading 20220105_155417.jpg…]()
我查看了PyTorch 0.10.0的官方文档与代码,ColorJitter
类的对象调用get_params
函数后返回的确实是一个元组。根据以上资料,请您将原始代码中第43至第46行替换为如下内容,您遇到的此问题应当可以得到解决。
I've looked up the official documentaion and code of torchvision 0.10.0, the type of the returning value of a ColorJitter
object when calling get_params
is tuple
indeed. According to references, please replace line 43~46 of the original code into these shown below, this problem you've been facing should be solved.
idx, brightness, contrast, saturation, hue = trans.get_params(trans.brightness, trans.contrast,
trans.saturation, trans.hue)
for img_no, trans_img in enumerate(trans_imgs):
for id in idx:
if id == 0 and brightness is not None:
trans_imgs[img_no] = F.adjust_brightness(trans_img, brightness)
elif id == 1 and contrast is not None:
trans_imgs[img_no] = F.adjust_contrast(trans_img, contrast)
elif id == 2 and saturation is not None:
trans_imgs[img_no] = F.adjust_saturation(trans_img, saturation)
elif id == 3 and hue is not None:
trans_imgs[img_no] = F.adjust_hue(trans_img, hue)
感谢!!已经调通了
您好,我用StanfordCars数据集训练,报如下错误,找了好久也没找到是什么原因,请看一下