Commit 3f4ff138 authored by shreyansh's avatar shreyansh

added 56 models

parent b34a1e61
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,21 +34,37 @@ sign = {
23:"y"
}
lastAns , consecutive = "",0
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
frame = cv2.flip(frame,1)
if ret:
cv2.rectangle(frame,(100,100),(300,300),(0,255,0),0)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
roi = gray[100:300, 100:300]
resized = cv2.resize(roi, (28,28), interpolation = cv2.INTER_AREA)
resized = resized.reshape(-1,28,28,1).astype(float)
print(sign[np.argmax(model.predict(resized))])
# Our operations on the frame come here
image = resized.reshape(-1,28,28,1).astype(float)
# Display the resulting frame
cv2.imshow('frame',gray)
a = cv2.waitKey(1) # waits to see if `esc` is pressed
softmax_output = model.predict(image)
if np.max(softmax_output) < 0.5:
continue
res = np.argmax(softmax_output)
lastAns = res
if res == lastAns:
consecutive+=1
else:
consecutive = 0
if cv2.waitKey(1) & 0xFF == ord('q'):
if consecutive == 10:
consecutive = 0
cv2.putText(frame, sign[res], (100,400), cv2.FONT_HERSHEY_SIMPLEX, 4, (255,255,255), 4)
cv2.imshow("new",roi)
cv2.imshow("frame", frame)
if a == 27: # when `esc` is pressed
break
# When everything done, release the capture
......
import pandas as pd
import numpy as np
import tensorflow as tf
from keras.models import Sequential,model_from_json,load_model
from keras.models import Sequential,load_model
from keras.layers import Dense, Conv2D, Flatten, MaxPooling2D, Dropout
from sklearn.preprocessing import LabelBinarizer
trainData = pd.read_csv("/content/drive/My Drive/Colab Notebooks/data/sign-language-mnist/sign_mnist_train.csv").values
testData = pd.read_csv("/content/drive/My Drive/Colab Notebooks/data/sign-language-mnist/sign_mnist_test.csv").values
trainData = pd.read_csv("data/sign_mnist_train.csv").values
testData = pd.read_csv("data/sign_mnist_test.csv").values
trainX,trainY = trainData[:,1:],LabelBinarizer().fit_transform(trainData[:,0:1])
testX,testY = testData[:,1:],LabelBinarizer().fit_transform(testData[:,0:1])
......@@ -30,7 +30,7 @@ model.add(Dense(128, activation = 'relu'))
model.add(Dropout(0.35))
model.add(Dense(24, activation = 'softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.compile(loss='logcosh', optimizer='adamax', metrics=['accuracy'])
trainX = trainX.reshape(trainX.shape[0], 28, 28, 1)
testX = testX.reshape(testX.shape[0], 28, 28, 1)
......@@ -39,6 +39,6 @@ model.fit(trainX, trainY, validation_data=(testX, testY), epochs=40, batch_size=
scores = model.evaluate(testX, testY, verbose=0)
model.save("/content/drive/My Drive/Colab Notebooks/data/model.h5")
model.save("models/model.h5")
print("CNN Error: %.2f%%" % (100-scores[1]*100))
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment