Omar2017:

import torch from torch.utils.data import Dataset from PIL import Image import numpy as np import cv2 class makeDataset(Dataset): def init(self, dataset, labels, spatial_transform, seqLen): self.spatial_transform = spatial_transform self.images = dataset self.labels = labels self.seqLen = seqLen def len(self): return len(self.images) def getitem(self, idx): vid_name = self.images[idx] label = self.labels[idx] inpSeq = [] vid=cv2.VideoCapture(vid_name) index=0 frame =None ret, frame = vid.read() while(index<=self.seqLen): # Extract images ret, frame = vid.read() if not ret: break index+=1 img=Image.fromarray(frame) inpSeq.append(self.spatial_transform(img.convert(‘RGB’))) inpSeq = torch.stack(inpSeq, 0) return inpSeq, label


Theres’ something wrong in your spatial transformation function. Are you sure that the spatial_transform generates output in the format (B,C,H,W) ?. Also self.seqLen can be inferred from the video in OpenCV.