Hi, I am a newbie to PyTorch, I am doing the image classification, please help me. how to transfer the image to tensors,
Here my code :
import cv2
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
import torch
import torchvision
import torchvision.transforms as transforms
file_path='dataset'
train=pd.read_csv(os.path.join(file_path,'train.csv'))
test=pd.read_csv(os.path.join(file_path,'test.csv'))
temp=[]
for img_name in train.Image:
img_path=os.path.join(file_path,'Train Images',img_name)
img=cv2.imread(img_path)
img=cv2.resize(img,(64,64))
temp.append(img)
train_x=np.asarray(temp)
transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
trainloader = torch.utils.data.DataLoader(train_x, batch_size=4,
shuffle=True, num_workers=2)
I tried this ,
but it is showing some module error.