diff --git a/ident-live.py b/ident-live.py new file mode 100644 index 0000000..ae3763e --- /dev/null +++ b/ident-live.py @@ -0,0 +1,45 @@ +#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 m import * +mod.load_weights("model3-val-acc-0.74.model.keras") + +c = cv.VideoCapture(0) + +while True: + ret, frame = c.read() + + pi = np.array(img(cv.cvtColor(frame, cv.COLOR_BGR2RGB)).resize((300, 300)).convert("RGB")) + #plt.imshow(pi) + #plt.show() + + #print(pi.astype(float)) + + r = mod.predict(np.array([pi.astype(float)])) + + cv.putText(frame, f"Y: {r[0][1]:.9f}", (10, 40), cv.FONT_HERSHEY_SIMPLEX, 1, (200,255,200), 2) + cv.putText(frame, f"N: {r[0][0]:.9f}", (10, 70), cv.FONT_HERSHEY_SIMPLEX, 1, (200,200,255), 2) + + cv.imshow('me', frame) + + if cv.waitKey(1) == ord('q'): + break + +#print(frame) + +c.release() +cv.destroyAllWindows() + +#r = mod.predict(np.array([i])) +#print(r) diff --git a/ident.py b/ident.py new file mode 100644 index 0000000..e8d04d9 --- /dev/null +++ b/ident.py @@ -0,0 +1,15 @@ +from m import * +from PIL import Image +from sys import argv, exit +import numpy as np + + +if len(argv) != 2: + exit(1) + +i = np.array(Image.open(argv[1]).convert('RGB').resize((300,300))) + +mod.load_weights("model3.model.keras") + +r = mod.predict(np.array([i])) +print(r)