I tested the videos in UCF101 on the trained VGG19 network (the training accuracy rate has reached 85%), but the results I got were all wrong classification.
May I ask what might be the reason? Thank you very much.
Here is my revised code, thank you very much.
`import torch
import numpy as np
from network import C3D_model
import cv2
from torch import nn
from torchvision import transforms
from PIL import Image
import config
import os
from model import CNNEncoder, RNNDecoder
torch.backends.cudnn.benchmark = True
I tested the videos in UCF101 on the trained VGG19 network (the training accuracy rate has reached 85%), but the results I got were all wrong classification.
May I ask what might be the reason? Thank you very much.
Here is my revised code, thank you very much.
`import torch import numpy as np
from network import C3D_model
import cv2 from torch import nn from torchvision import transforms from PIL import Image import config import os from model import CNNEncoder, RNNDecoder torch.backends.cudnn.benchmark = True
def CenterCrop(frame, size): h, w = np.shape(frame)[0:2] th, tw = size x1 = int(round((w - tw) / 2.)) y1 = int(round((h - th) / 2.))
def center_crop(frame):
frame = frame[8:120, 30:142, :]
def transform(self, img): return transforms.Compose([ transforms.Resize((config.img_w, config.img_h)), transforms.ToTensor(), transforms.Normalize( mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225] ) ])(img) def main(): device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") print("Device being used:", device)
cap = cv2.VideoCapture(0)
if name == 'main': main()
`