import streamlit as st import cv2 import numpy as np import os import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import LSTM, Dense, Dropout from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard import mediapipe as mp from utils.data_utils import process_video, extract_landmarks from utils.model_utils import create_model, convert_to_tflite def main(): st.title("Sign Language Model Training Platform") # Sidebar for training configuration st.sidebar.header("Training Configuration") # Model parameters num_classes = st.sidebar.number_input("Number of Sign Classes", min_value=2, value=10) epochs = st.sidebar.number_input("Training Epochs", min_value=1, value=50) batch_size = st.sidebar.number_input("Batch Size", min_value=1, value=32) # Dataset upload st.header("Dataset Upload") dataset_path = st.file_uploader("Upload Dataset (ZIP file containing video folders)", type=['zip']) if dataset_path: # Create progress bar progress_bar = st.progress(0) status_text = st.empty() # Extract dataset status_text.text("Extracting dataset...") # TODO: Add dataset extraction logic # Process videos and extract landmarks status_text.text("Processing videos and extracting landmarks...") X_train, y_train = [], [] # TODO: Add video processing logic using MediaPipe # Create and train model if st.button("Start Training"): status_text.text("Creating model...") model = create_model(num_classes) status_text.text("Training model...") history = model.fit( X_train, y_train, epochs=epochs, batch_size=batch_size, validation_split=0.2, callbacks=[ ModelCheckpoint('models/best_model.h5', save_best_only=True), TensorBoard(log_dir='logs') ] ) # Convert to TFLite status_text.text("Converting model to TFLite...") convert_to_tflite(model, 'models/model.tflite') st.success("Training completed! Model saved as 'model.tflite'") # Display training metrics st.header("Training Results") st.line_chart(history.history) if __name__ == "__main__": main()