import gradio as gr import numpy as np import tensorflow as tf from tensorflow.keras.models import load_model from sklearn.preprocessing import MinMaxScaler # Load the saved model model = load_model('lstm_model') # Dummy scaler (replace this with the actual scaler used in training) scaler = MinMaxScaler(feature_range=(0, 1)) # Function for Prediction def predict_sales(input_data): # Reshape and scale input data input_data = np.array(input_data).reshape(1, 30, 1) scaled_input = scaler.transform(input_data) # Predict prediction = model.predict(scaled_input) actual_prediction = scaler.inverse_transform(prediction) return actual_prediction[0][0] # Gradio Interface inputs = gr.inputs.Dataframe(headers=["Sales"], type="numpy", row_count=30, col_count=1) outputs = gr.outputs.Textbox() interface = gr.Interface(fn=predict_sales, inputs=inputs, outputs=outputs, title="LSTM Sales Forecasting") interface.launch()