pushpikaLiyanagama's picture
Update app.py
4277877 verified
raw
history blame
1.25 kB
import gradio as gr
import joblib
import numpy as np
# Load the scaler and models
scaler = joblib.load('scaler.joblib')
models = {
"processing": joblib.load('svm_model_processing.joblib'),
"perception": joblib.load('svm_model_perception.joblib'),
"input": joblib.load('svm_model_input.joblib'),
"understanding": joblib.load('svm_model_understanding.joblib'),
}
# Define the prediction function
def predict(user_input):
user_input_array = np.array(user_input).reshape(1, -1)
user_input_scaled = scaler.transform(user_input_array)
predictions = {target: model.predict(user_input_scaled)[0] for target, model in models.items()}
return predictions
# Define the interface
interface = gr.Interface(
fn=predict,
inputs=gr.Dataframe(type="numpy", row_count=1, col_count=12,
headers=["course overview", "reading file", "abstract materiale",
"concrete material", "visual materials", "self-assessment",
"exercises submit", "quiz submitted", "playing", "paused",
"unstarted", "buffering"]),
outputs=gr.JSON(),
live=True
)
# Define the callable object for inference
model = interface