import gradio as gr import pickle import numpy as np from tensorflow import keras from tensorflow.keras.models import load_model # Load the model and scalers model1 = load_model('/home/user/app/model.h5') scaler_x = pickle.load(open('/home/user/app/scaler.pkl', 'rb')) scaler_y = pickle.load(open('/home/user/app/scaler_y.pkl', 'rb')) def SPT_fee(stress, N): x = np.array([stress, N]) x = np.reshape(x, (1, 2)) x_scale = scaler_x.transform(x) y_scale = model1.predict(x_scale) y_scale = np.reshape(y_scale, (1, 1)) y = scaler_y.inverse_transform(y_scale) # state parameter # calculate friction angle fee = 34.821 - 27.512 * y return f"Friction angle: {fee[0,0]:.2f} degrees" # Create Gradio interface iface = gr.Interface( fn=SPT_fee, inputs=[ gr.Number(label="Stress (kPa)", value=100), gr.Number(label="N value", value=3) ], outputs="text", title="SPT Friction Angle Calculator of Bangkok Sand (Youwai and Wongsala,2024) ", description="Calculate friction angle based on stress and N value." ) # Launch the interface iface.launch()