0
以下のように複数の画像を保存しました。Pytorch画像をテンソルに変換する方法
for name in image_names:
images.append(cv2.imread("./train_mini/"+name))
CNNトレーニングでこれらの画像を後で使用したいと思います。私は以下のような「torch.utils.data.TensorDataset」でそれらのデータを保存した場合しかし、それはエラーを示しています
“RuntimeError: can’t convert a given np.ndarray to a tensor - it has an invalid type. The only supported types are: double, float, int64, int32, and uint8.”
だから私は、画像のデータ型をチェックし、それが「オブジェクト」でした。
train = torch.utils.data.TensorDataset(torch.from_numpy(X_train), torch.from_numpy(Y_train))
どうすればこの問題を解決できますか?私は完全に固執しています...
[こちらを読む](https://stackoverflow.com/questions/3386259/how-to-make-a-multidimension-numpy-array-with-a-varying-row-size)異なる形状の配列のリストまた、 'TensorDataset'に配列のリストを渡すこともできます。' torch.from_numpy() 'を実行する必要はありません。 –
ありがとうございます!これは、インストールイメージのサイズがさまざまだったためです。 –