import streamlit as st from tensorflow.keras.models import load_model from PIL import Image, ImageOps import numpy as np model = load_model('src/sign_model.h5') def process_image(img): img = img.convert('L') img = img.resize((28, 28)) img = np.array(img) img = img / 255.0 # Reshape to (1, 28, 28, 1) img = img.reshape(1, 28, 28, 1) return img st.title("Sign Language Classification") st.write("Upload an image of a hand sign (A-Y) and the model will predict the letter.") file = st.file_uploader('Select an image', type=['jpg', 'jpeg', 'png']) if file is not None: img = Image.open(file) st.image(img, caption='Uploaded Image', width=200) image = process_image(img) prediction = model.predict(image) predicted_class = np.argmax(prediction) class_names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'] if predicted_class < len(class_names): result = class_names[predicted_class] else: result = str(predicted_class) st.write(f"Prediction: **{result}**")