当前位置:网站首页>transforms. The input of randomcrop() can only be PIL image, not tensor

transforms. The input of randomcrop() can only be PIL image, not tensor

2022-06-26 17:51:00 LIZHEMGHONG

This is the original code
 Insert picture description here
Report errors :TypeError: ‘builtin_function_or_method’ object is not iterable
 Insert picture description here

This is the changed code
 Insert picture description here
Report errors :TypeError: img should be PIL Image. Got <class ‘torch.Tensor’>
 Insert picture description here
So I type in tensor It is not right , You should enter PIL image

However, I read a lot of information on the Internet that this function is correct tensor and PIL Fine , I don 't know which one is right , I think I can only input PIL image It can't be tensor

I replace the input with data_i_pil = transforms.ToPILImage()(data_i) After that, the program can run normally

Many people on the Internet say that this function is right tensor and PIL Fine , It's not , Let me give you an example , The following link is one of them
link :https://www.jianshu.com/p/ae695df39274

原网站

版权声明
本文为[LIZHEMGHONG]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261742207192.html