📜  TypeError: default_collate: batch 必须包含张量、numpy 数组、数字、dicts 或列表;成立<class 'PIL.Image.Image'>- 打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:15.204000             🧑  作者: Mango

代码示例1
The error states that the DataLoader receives a PIL image. 
This is because there are no transforms made (transform=None) on the image.
You can add a transform that creates a tensor from the PIL image by adding transform:

from torchvision import transforms

transform = transforms.Compose([
    # you can add other transformations in this list
    transforms.ToTensor()
])