How to prepare the Image data for RNN model

Hi, I am newbie to PyTorch, I am doing an image classification problem, Please help me how to prepare the data for the RNN model.
my Data looks like you:

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'))
train.head()
Image	Class
0	image7042.jpg	Food
1	image3327.jpg	misc
2	image10335.jpg	Attire
3	image8019.jpg	Food
4	image2128.jpg	Attire

I prepared my data using OpenCV like this:

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))
    emp.append(img)
y=train['Class'].map({"Food":0,"misc":1,"Attire":2,"Decorationandsignage":3})

How would you like to pass our images to an RNN?
The default input shape would be [seq_len, batch_size, nb_features].
If you are working on a multi-class classification, I assume you would like to use nn.CrossEntropyLoss?

1 Like