Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
ML725
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SHREYANSH JAIN
ML725
Commits
8c7d7df9
Commit
8c7d7df9
authored
Nov 06, 2019
by
shreyansh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model added
parent
3ff16728
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
2 deletions
+81
-2
sign-language/.vscode/settings.json
sign-language/.vscode/settings.json
+3
-0
sign-language/main.py
sign-language/main.py
+34
-2
sign-language/prediction.py
sign-language/prediction.py
+44
-0
No files found.
sign-language/.vscode/settings.json
0 → 100644
View file @
8c7d7df9
{
"python.pythonPath"
:
"/home/shreyansh/.conda/envs/ml725/bin/python"
}
\ No newline at end of file
sign-language/main.py
View file @
8c7d7df9
...
...
@@ -7,15 +7,47 @@ cap = cv2.VideoCapture(0)
model
=
tf
.
keras
.
models
.
load_model
(
"models/model.h5"
)
print
(
"Loaded model from disk"
)
sign
=
{
0
:
"a"
,
1
:
"b"
,
2
:
"c"
,
3
:
"d"
,
4
:
"e"
,
5
:
"f"
,
6
:
"g"
,
7
:
"h"
,
8
:
"i"
,
9
:
"k"
,
10
:
"l"
,
11
:
"m"
,
12
:
"n"
,
13
:
"o"
,
14
:
"p"
,
15
:
"q"
,
16
:
"r"
,
17
:
"s"
,
18
:
"t"
,
19
:
"u"
,
20
:
"v"
,
21
:
"w"
,
22
:
"x"
,
23
:
"y"
}
while
(
True
):
# Capture frame-by-frame
ret
,
frame
=
cap
.
read
()
# Our operations on the frame come here
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
# Display the resulting frame
cv2
.
imshow
(
'frame'
,
gray
)
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'q'
):
break
...
...
sign-language/prediction.py
0 → 100644
View file @
8c7d7df9
import
pandas
as
pd
import
numpy
as
np
import
tensorflow
as
tf
from
keras.models
import
Sequential
,
model_from_json
,
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
trainX
,
trainY
=
trainData
[:,
1
:],
LabelBinarizer
()
.
fit_transform
(
trainData
[:,
0
:
1
])
testX
,
testY
=
testData
[:,
1
:],
LabelBinarizer
()
.
fit_transform
(
testData
[:,
0
:
1
])
trainX
=
np
.
divide
(
trainX
,
255
)
testX
=
np
.
divide
(
testX
,
255
)
# create model
model
=
Sequential
()
model
.
add
(
Conv2D
(
64
,
kernel_size
=
(
3
,
3
),
activation
=
'relu'
,
input_shape
=
(
28
,
28
,
1
)
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
64
,
kernel_size
=
(
3
,
3
),
activation
=
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
64
,
kernel_size
=
(
3
,
3
),
activation
=
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Flatten
())
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'
])
trainX
=
trainX
.
reshape
(
trainX
.
shape
[
0
],
28
,
28
,
1
)
testX
=
testX
.
reshape
(
testX
.
shape
[
0
],
28
,
28
,
1
)
model
.
fit
(
trainX
,
trainY
,
validation_data
=
(
testX
,
testY
),
epochs
=
40
,
batch_size
=
128
)
# Final evaluation of the model
scores
=
model
.
evaluate
(
testX
,
testY
,
verbose
=
0
)
model
.
save
(
"/content/drive/My Drive/Colab Notebooks/data/model.h5"
)
print
(
"CNN Error:
%.2
f
%%
"
%
(
100
-
scores
[
1
]
*
100
))
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment