Upload and preprocess single video for video classification


I am new to pytorch.
I have a pretrained model and I want to try with a SINGLE video.
The video is already in frames (35 frames)
How can I import the frames and preprocess them?

Thank you for your help

I think you can read the video file using opencv. Take a look at this.

Hi @Isaac_Kargar,
Thank you for your answer, the tuto that you gave me is for videos which is nice. (I am keeping it)
But in this case the video is already in frames and I already have the images. I want to upload them and pass them to the model.


I want to upload those images and pass them to the model.

So you can use ImageFolder for data loader. Check this. You also need to set shuffle=False if the sequence is important. Or you can use general dataloader class like this. in the __getitem__ method you need to load images, process them and return them and in the training loop feed them into the model.

Hi @Isaac_Kargar
Thank you very much for your answer.
So I am using a pretrained model and now I want to try with only this video.
I have no other videos just one that I picked myself and want to see if the model is going to classify it right or not.
If I got it right: ImageFolder is for huge dataset right?
Do you have any suggestion?

I usually myself write a custom class and read the file names in init and do sorting and everything there. Then in getitem method load the image and do processes and return the input and the label.