add identification scripts
This commit is contained in:
parent
0f4ebce8f6
commit
347f6a2483
45
ident-live.py
Normal file
45
ident-live.py
Normal file
@ -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)
|
||||
15
ident.py
Normal file
15
ident.py
Normal file
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user