我正在使用 Pytorch 的自定义数据集功能从一个文件夹中的单独文件创建自定义数据集。每个文件包含 123 行 123 列,所有数据点均为整数。
我的问题是我遇到的资源可以满足一个 .csv 中的文件,而我的不是。更重要的是,在转换为图像后打开图像也不会运行。我不知道如何从这里开始,因为我的代码给出了:
Public Sub EmptyFolder()
Dim Items As Outlook.Items
Dim i As Long
Dim Count As Long
Dim Delete As Boolean
' Clear Junk Items
Set ns = Application.GetNamespace("MAPI")
Set Items = Session.GetDefaultFolder(olFolderCalendar).Parent.Folders("Junk").Items
Count = Items.Count
If Count = 0 Then
GoTo DeleteAll
End If
Delete = True
For i = Count To 1 Step -1
Items(i).Delete
Next
DeleteAll:
' Clear Trash Items
Set Items = Session.GetDefaultFolder(olFolderCalendar).Parent.Folders("Trash").Items
Count = Items.Count
If Count = 0 Then
GoTo EndAll
End If
Delete = True
For i = Count To 1 Step -1
Items(i).Delete
Next
EndAll:
End Sub
AttributeError: 'Image' object has no attribute 'read'
答案 0 :(得分:0)
PIL.Image.fromarray
用于将数组转换为 PIL Image,而 Image.open
用于从文件系统加载图像文件。您不需要这两个中的任何一个,因为您已经有一个 NumPy 数组来表示您的图像并希望返回它。如果您将数据集插入 torch.data.utils.DataLoader
,PyTorch 会自动将其转换为 torch.Tensor
。