File size: 897 Bytes
d767156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import cv2
import numpy as np


def video_Frames(clip_path,img_size = 64):
    video = cv2.VideoCapture(clip_path)
    frame_count = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
    for count in range(frame_count):
        flag, frame = video.read()
        if not flag:
            break
        frame = cv2.resize(frame,(img_size,img_size))
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 
        #normalizing the pixels between 0 and 1
        frame = frame/255.0
        yield frame 
    video.release()


def load_video(folder_path):
    imgs = []
    frames_generator = video_Frames(folder_path)
    frames_array = np.array(list(frames_generator))
    imgs.append(frames_array)
    real_imgs = np.array(imgs)

    return imgs


def eval_real(real_imgs, model):    
    pred1 = model.predict(real_imgs)
    pred1_max = pred1.argmax()

    return pred1_max