Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,25 @@
|
|
| 1 |
import joblib
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
# Load model
|
| 5 |
model = joblib.load("./scaler.pkl")
|
| 6 |
|
| 7 |
# Prediction function
|
| 8 |
def predict(val1, val2):
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# UI
|
| 13 |
gr.Interface(
|
| 14 |
fn=predict,
|
| 15 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
| 16 |
outputs="text"
|
| 17 |
-
).launch()
|
|
|
|
| 1 |
import joblib
|
| 2 |
import gradio as gr
|
| 3 |
+
import numpy as np
|
| 4 |
|
| 5 |
# Load model
|
| 6 |
model = joblib.load("./scaler.pkl")
|
| 7 |
|
| 8 |
# Prediction function
|
| 9 |
def predict(val1, val2):
|
| 10 |
+
try:
|
| 11 |
+
data = np.array([[float(val1), float(val2)]])
|
| 12 |
+
prediction = model.predict(data)
|
| 13 |
+
return str(prediction[0])
|
| 14 |
+
except Exception as e:
|
| 15 |
+
return f"Error: {str(e)}"
|
| 16 |
|
| 17 |
# UI
|
| 18 |
gr.Interface(
|
| 19 |
fn=predict,
|
| 20 |
+
inputs=[
|
| 21 |
+
gr.Number(label="CGPA"),
|
| 22 |
+
gr.Number(label="IQ")
|
| 23 |
+
],
|
| 24 |
outputs="text"
|
| 25 |
+
).launch()
|