39 lines
705 B
Python
39 lines
705 B
Python
|
|
#from PIL import Image
|
||
|
|
from sys import argv, exit
|
||
|
|
import numpy as np
|
||
|
|
import cv2 as cv
|
||
|
|
|
||
|
|
from tensorflow.keras.utils import array_to_img as img
|
||
|
|
|
||
|
|
from matplotlib import pyplot as plt
|
||
|
|
|
||
|
|
if len(argv) != 2:
|
||
|
|
exit(1)
|
||
|
|
|
||
|
|
#i = np.array(Image.open(argv[1]).convert('RGB').resize((300,300)))
|
||
|
|
|
||
|
|
from test2 import *
|
||
|
|
m.load_weights("model3.keras")
|
||
|
|
|
||
|
|
c = cv.VideoCapture(argv[1])
|
||
|
|
|
||
|
|
frames = []
|
||
|
|
|
||
|
|
while True:
|
||
|
|
ret, frame = c.read()
|
||
|
|
|
||
|
|
if not ret:
|
||
|
|
break
|
||
|
|
|
||
|
|
r = cv.resize(frame, dsize=(300, 300), interpolation=cv.INTER_CUBIC)
|
||
|
|
r = cv.cvtColor(r, cv.COLOR_BGR2RGB)
|
||
|
|
frames.append(r)
|
||
|
|
|
||
|
|
c.release()
|
||
|
|
|
||
|
|
frames = np.array(frames)
|
||
|
|
res = m.predict(frames, batch_size = 64)
|
||
|
|
|
||
|
|
plt.plot([i[0] for i in res])
|
||
|
|
plt.show()
|