Skip to content

Commit 6aaea30

Browse files
committed
Update
1 parent a3fec9e commit 6aaea30

File tree

2 files changed

+103
-12
lines changed

2 files changed

+103
-12
lines changed

README.md

Lines changed: 103 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,135 @@ The project was completed in 24 hours as part of final HackUNT19, the University
1717
## General info
1818

1919
The theme at HACK UNT 19 was to use technology to improve accessibility by finding a creative solution to benefit the lives of those with disability.
20-
We wanted to make it easy for 70 million deaf people across the world to be independent of translators for there daily communication needs.
20+
We wanted to make it easy for 70 million deaf people across the world to be independent of translators for there daily communication needs, so we designed the app to work as a personal translator 24*7 for the deaf people.
2121

2222

2323
## Screenshots
24-
![Example screenshot](./img/Capture.PNG)
24+
![Example screenshot](./img/Capture1.PNG)
2525
![Example screenshot](./img/Capture.PNG)
2626
![Example screenshot](./img/Capture2.PNG)
2727
![Example screenshot](./img/Capture3.PNG)
2828

2929
## Technologies and Tools
30-
* Python - version 3.5
30+
* Python
3131
* TensorFlow
3232
* Keras
33+
* OpenCV
3334

3435
## Setup
35-
Describe how to install / setup your local environement / add link to demo version.
36+
37+
* Use comand promt to setup environment by using requirements_cpu.txt and requirements_gpu.txt
38+
`pyton -m pip r using requirements_cpu.txt`
39+
40+
This will help you in installing all the libraries required for the project.
41+
3642

3743
## Process
3844

45+
* Run set_hand_hist.py to set the hand histogram for creating gestures.
46+
* Once you get a good histogram, save it in the code folder, or you can use the histogram created by us that can be found [here]().
47+
* Added gestures and lable them using OpenCV which uses webcam feed by running `create_gestures.py` and stores them in a database. Alternately, you can use the gestures created by us [here]()
48+
* Add different variations to the captured gestures by flipping all the images by uing `flip_images.py`
49+
* Run `load_images.py` to split all the captured gestures into training, validation and test set.
50+
* To view all the gestures, run `display_all_gestures.py`
51+
* Train the model using Keras by running `cnn_keras.py`
52+
* Run `fun_util.py`. This will open up tghe gesture recognition window which will use your webcam to interpret the trained American Sign Language gestures.
53+
3954
## Code Examples
40-
Some examples of usage:
4155

4256
````
57+
# Model Traiining using CNN
58+
59+
import numpy as np
60+
import pickle
61+
import cv2, os
62+
from glob import glob
63+
from keras import optimizers
64+
from keras.models import Sequential
65+
from keras.layers import Dense
66+
from keras.layers import Dropout
67+
from keras.layers import Flatten
68+
from keras.layers.convolutional import Conv2D
69+
from keras.layers.convolutional import MaxPooling2D
70+
from keras.utils import np_utils
71+
from keras.callbacks import ModelCheckpoint
72+
from keras import backend as K
73+
K.set_image_dim_ordering('tf')
74+
75+
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
76+
77+
def get_image_size():
78+
img = cv2.imread('gestures/1/100.jpg', 0)
79+
return img.shape
80+
81+
def get_num_of_classes():
82+
return len(glob('gestures/*'))
83+
84+
image_x, image_y = get_image_size()
85+
86+
def cnn_model():
87+
num_of_classes = get_num_of_classes()
88+
model = Sequential()
89+
model.add(Conv2D(16, (2,2), input_shape=(image_x, image_y, 1), activation='relu'))
90+
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='same'))
91+
model.add(Conv2D(32, (3,3), activation='relu'))
92+
model.add(MaxPooling2D(pool_size=(3, 3), strides=(3, 3), padding='same'))
93+
model.add(Conv2D(64, (5,5), activation='relu'))
94+
model.add(MaxPooling2D(pool_size=(5, 5), strides=(5, 5), padding='same'))
95+
model.add(Flatten())
96+
model.add(Dense(128, activation='relu'))
97+
model.add(Dropout(0.2))
98+
model.add(Dense(num_of_classes, activation='softmax'))
99+
sgd = optimizers.SGD(lr=1e-2)
100+
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
101+
filepath="cnn_model_keras2.h5"
102+
checkpoint1 = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
103+
callbacks_list = [checkpoint1]
104+
#from keras.utils import plot_model
105+
#plot_model(model, to_file='model.png', show_shapes=True)
106+
return model, callbacks_list
107+
108+
def train():
109+
with open("train_images", "rb") as f:
110+
train_images = np.array(pickle.load(f))
111+
with open("train_labels", "rb") as f:
112+
train_labels = np.array(pickle.load(f), dtype=np.int32)
113+
114+
with open("val_images", "rb") as f:
115+
val_images = np.array(pickle.load(f))
116+
with open("val_labels", "rb") as f:
117+
val_labels = np.array(pickle.load(f), dtype=np.int32)
118+
119+
train_images = np.reshape(train_images, (train_images.shape[0], image_x, image_y, 1))
120+
val_images = np.reshape(val_images, (val_images.shape[0], image_x, image_y, 1))
121+
train_labels = np_utils.to_categorical(train_labels)
122+
val_labels = np_utils.to_categorical(val_labels)
123+
124+
print(val_labels.shape)
125+
126+
model, callbacks_list = cnn_model()
127+
model.summary()
128+
model.fit(train_images, train_labels, validation_data=(val_images, val_labels), epochs=15, batch_size=500, callbacks=callbacks_list)
129+
scores = model.evaluate(val_images, val_labels, verbose=0)
130+
print("CNN Error: %.2f%%" % (100-scores[1]*100))
131+
#model.save('cnn_model_keras2.h5')
132+
133+
train()
134+
K.clear_session();
43135
44136
````
45137

46138
## Features
47-
List of features ready and TODOs for future development
48-
* Awesome feature 1
49-
* Awesome feature 2
50-
* Awesome feature 3
139+
Our model was able to predict the 44 characters in the ASL with a prediction accuracy >95%.
51140

52141
To-do list:
53-
* Wow improvement to be done 1
54-
* Wow improvement to be done 2
142+
* Deploy the project on cloud and create an API for using it.
143+
* Increase the vocabulary of our model
144+
* Incorporate feedback mechanism to make the model more robust
145+
* Add more sign languages
55146

56147
## Status
57-
Project is: _in progress_. Although we did finish the project and make a su and why?
148+
Project is: _finished_. Our team was the winner of the UNT Hackaton 2019. You can find the our final submission post on [devpost](http://bit.ly/2WWllwg).
58149

59150
## Contact
60151
Created by me and my teammates [Siddharth Oza](https://github.com/siddharthoza), [Ashish Sharma](https://github.com/ashish1993utd), and [Manish Shukla](https://github.com/Manishms18).

img/Capture1.PNG

47.9 KB
Loading

0 commit comments

Comments
 (0)