|
import streamlit as st |
|
import tensorflow as tf |
|
import cv2 |
|
import numpy as np |
|
|
|
def run(): |
|
|
|
model = tf.keras.models.load_model("best_model.h5") |
|
|
|
|
|
label_names = ['a', 'b', 'c', 'd', 'e', 'del', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'not', 'o', |
|
'p', 'q', 'r', 's', 't', 'space', 'u', 'v', 'w', 'x', 'y', 'z'] |
|
|
|
|
|
st.title("ASL image Prediction") |
|
st.write("Choose an image to classify.") |
|
|
|
|
|
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"]) |
|
|
|
if uploaded_file is not None: |
|
|
|
img = tf.keras.utils.load_img(uploaded_file, target_size=(150, 150, 3)) |
|
|
|
|
|
x = tf.keras.utils.img_to_array(img) |
|
|
|
|
|
x = np.expand_dims(x, axis=0) |
|
|
|
|
|
x = x / 255.0 |
|
|
|
|
|
y_pred = model.predict(x) |
|
|
|
|
|
class_idx = np.argmax(y_pred, axis=1)[0] |
|
|
|
|
|
st.write(f"Detection for uploaded image: {label_names[class_idx]}") |
|
st.image(img, caption=f"{label_names[class_idx]}", use_column_width=True) |
|
|
|
|
|
if __name__=="__main__": |
|
run() |