Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- ASL_CNN_model.h5 +3 -0
- app.py +47 -0
- l-sign-language-fd31b4ca-e8746b6c-640w.webp +0 -0
- label_list.pkl +3 -0
- lvb-cornuto5.webp +0 -0
- sign-language-hand-showing-c-260nw-740041291.webp +0 -0
ASL_CNN_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2411e6cf89a776235c95eb50a9f895d1c874f3b4b01400a11e2df542a6c970b
|
| 3 |
+
size 30696276
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
from tensorflow.keras.preprocessing import image
|
| 5 |
+
import matplotlib.pyplot as plt
|
| 6 |
+
import pickle
|
| 7 |
+
|
| 8 |
+
# Load the saved model
|
| 9 |
+
model = load_model("ASL_CNN_model.h5")
|
| 10 |
+
|
| 11 |
+
with open('label_list.pkl', 'rb') as f:
|
| 12 |
+
index_to_label = pickle.load(f)
|
| 13 |
+
|
| 14 |
+
IMG_HEIGHT = 128
|
| 15 |
+
IMG_WIDTH = 128
|
| 16 |
+
|
| 17 |
+
def predict_sign_language(img):
|
| 18 |
+
# Preprocess the image
|
| 19 |
+
img = img.resize((IMG_HEIGHT, IMG_WIDTH))
|
| 20 |
+
img_array = image.img_to_array(img)
|
| 21 |
+
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
|
| 22 |
+
img_array = img_array / 255.0 # Normalize if needed
|
| 23 |
+
|
| 24 |
+
# Make predictions
|
| 25 |
+
predictions = model.predict(img_array)
|
| 26 |
+
predicted_index = np.argmax(predictions[0]) # Get the index with the highest probability
|
| 27 |
+
predicted_label = index_to_label[predicted_index]
|
| 28 |
+
|
| 29 |
+
return predicted_label
|
| 30 |
+
|
| 31 |
+
# Create a Gradio interface
|
| 32 |
+
iface = gr.Interface(
|
| 33 |
+
fn=predict_sign_language,
|
| 34 |
+
inputs=gr.Image(type="pil", label="Input Image"), # Use 'pil' type to get a PIL image
|
| 35 |
+
outputs=gr.Textbox(label="Predicted Label"),
|
| 36 |
+
title="Sign Language Predictor",
|
| 37 |
+
description="<div style='text-align: center;'>Upload an image and the model will predict the sign language.</div>",
|
| 38 |
+
examples=[
|
| 39 |
+
["l-sign-language-fd31b4ca-e8746b6c-640w.webp"],
|
| 40 |
+
["lvb-cornuto5.webp"],
|
| 41 |
+
["sign-language-hand-showing-c-260nw-740041291.webp"]
|
| 42 |
+
]
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
# Launch the interface
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
iface.launch()
|
l-sign-language-fd31b4ca-e8746b6c-640w.webp
ADDED
|
label_list.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe39aef0b1ffba4ba863c8623955d85fdb4f89e7cd688a61a8e0f6a23e699eab
|
| 3 |
+
size 243
|
lvb-cornuto5.webp
ADDED
|
sign-language-hand-showing-c-260nw-740041291.webp
ADDED
|