Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Load saved model and scaler
|
| 6 |
+
model = joblib.load("best_svr_model.pkl")
|
| 7 |
+
scaler = joblib.load("scaler.pkl")
|
| 8 |
+
|
| 9 |
+
def predict_wear(load, particle_size, sliding_speed):
|
| 10 |
+
input_data = np.array([[load, particle_size, sliding_speed]])
|
| 11 |
+
scaled_input = scaler.transform(input_data)
|
| 12 |
+
prediction = model.predict(scaled_input)
|
| 13 |
+
return round(prediction[0], 4)
|
| 14 |
+
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=predict_wear,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Number(label="Load (N)"),
|
| 19 |
+
gr.Number(label="Particle Size (μm)"),
|
| 20 |
+
gr.Number(label="Sliding Speed (mm/s)")
|
| 21 |
+
],
|
| 22 |
+
outputs=gr.Number(label="Predicted Volume Loss (mm³/s)"),
|
| 23 |
+
title="Wear Performance Prediction",
|
| 24 |
+
description="SVR Model to predict wear volume loss based on input parameters."
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
iface.launch()
|