Spaces:
Runtime error
Runtime error
Commit ·
3a7370e
1
Parent(s): ba8f9cc
Upload 4 files
Browse files- ASLimg.JPG +0 -0
- ASLmodelF.h5 +3 -0
- app.py +64 -0
- requirements.txt +11 -0
ASLimg.JPG
ADDED
|
|
ASLmodelF.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5650de58254be07efbc29801b40f2dae16a7898d33d5261a62eaaeed6c9e78e
|
| 3 |
+
size 14532992
|
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import numpy as np
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import cv2
|
| 5 |
+
import av
|
| 6 |
+
import mediapipe as mp
|
| 7 |
+
from streamlit_webrtc import webrtc_streamer, RTCConfiguration
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Initializing the Model
|
| 11 |
+
mpHands = mp.solutions.hands
|
| 12 |
+
hands = mpHands.Hands()
|
| 13 |
+
|
| 14 |
+
# Initializing the drawing utils for drawing the landmarks on image
|
| 15 |
+
mpDraw = mp.solutions.drawing_utils
|
| 16 |
+
mpDrawingStyle = mp.solutions.drawing_styles
|
| 17 |
+
|
| 18 |
+
# Load the Trained model of Sign Language
|
| 19 |
+
model = tf.keras.models.load_model('ASLmodelF.h5')
|
| 20 |
+
|
| 21 |
+
RTC_CONFIGURATION = RTCConfiguration({"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]})
|
| 22 |
+
ASLimg = cv2.imread('ASLimg.JPG')
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
label = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
| 26 |
+
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
| 27 |
+
|
| 28 |
+
# cap = cv2.VideoCapture(0)
|
| 29 |
+
class signDetection:
|
| 30 |
+
def recv(self, frame):
|
| 31 |
+
img = frame.to_ndarray(format="bgr24")
|
| 32 |
+
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 33 |
+
lmsList = []
|
| 34 |
+
result = hands.process(imgRGB)
|
| 35 |
+
if result.multi_hand_landmarks:
|
| 36 |
+
handLms = result.multi_hand_landmarks[0]
|
| 37 |
+
for lm in handLms.landmark:
|
| 38 |
+
h, w, c = img.shape
|
| 39 |
+
lmsList.append(lm.x)
|
| 40 |
+
lmsList.append(lm.y)
|
| 41 |
+
mpDraw.draw_landmarks(img, handLms, mpHands.HAND_CONNECTIONS, mpDrawingStyle.get_default_hand_landmarks_style(),
|
| 42 |
+
mpDrawingStyle.get_default_hand_connections_style())
|
| 43 |
+
lmsList = [lmsList]
|
| 44 |
+
lmsList = np.array(lmsList)
|
| 45 |
+
r = model.predict(lmsList)
|
| 46 |
+
r = np.argmax(r)
|
| 47 |
+
cv2.putText(img, f'Result = {label[r]}', (50, 40), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)
|
| 48 |
+
return av.VideoFrame.from_ndarray(img, format='bgr24')
|
| 49 |
+
|
| 50 |
+
def main():
|
| 51 |
+
st.title('Real Time Sign Language Detection')
|
| 52 |
+
|
| 53 |
+
st.header('Webcam Live Feed')
|
| 54 |
+
st.write("Click on start to use webcam and detect finger spellings")
|
| 55 |
+
webrtc_streamer(key='key', rtc_configuration=RTC_CONFIGURATION, video_processor_factory=signDetection)
|
| 56 |
+
|
| 57 |
+
with st.sidebar:
|
| 58 |
+
st.header('Finger Spellings')
|
| 59 |
+
st.image(image=ASLimg)
|
| 60 |
+
st.markdown('**Created by:** Manish Kumar')
|
| 61 |
+
st.markdown('Github Link: [ASL-Recognition](https://github.com/ManishKumar219/ASL-Recognition)')
|
| 62 |
+
|
| 63 |
+
if __name__ == "__main__":
|
| 64 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
numpy
|
| 3 |
+
matplotlib
|
| 4 |
+
scikit-learn
|
| 5 |
+
opencv-python
|
| 6 |
+
streamlit
|
| 7 |
+
streamlit_webrtc
|
| 8 |
+
mediapipe
|
| 9 |
+
tensorflow
|
| 10 |
+
keras
|
| 11 |
+
av
|