Skip to content

Commit

Permalink
Adds template file
Browse files Browse the repository at this point in the history
  • Loading branch information
PelumiAdeboye committed Jun 2, 2023
1 parent 530a3a0 commit 0df4471
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions RPS-Template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import cv2
from keras.models import load_model
import numpy as np
model = load_model('keras_model.h5')
cap = cv2.VideoCapture(0)
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)

while True:
ret, frame = cap.read()
resized_frame = cv2.resize(frame, (224, 224), interpolation = cv2.INTER_AREA)
image_np = np.array(resized_frame)
normalized_image = (image_np.astype(np.float32) / 127.0) - 1 # Normalize the image
data[0] = normalized_image
prediction = model.predict(data)
cv2.imshow('frame', frame)
# Press q to close the window
print(prediction)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# After the loop release the cap object
cap.release()
# Destroy all the windows
cv2.destroyAllWindows()

0 comments on commit 0df4471

Please sign in to comment.