add gradio
Browse files
app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
import joblib
|
| 2 |
-
import gradio as gr
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
|
| 5 |
-
# Load
|
| 6 |
model = joblib.load("model.joblib")
|
| 7 |
|
| 8 |
-
# Define prediction function
|
| 9 |
-
def predict(input1, input2, input3):
|
| 10 |
-
|
| 11 |
-
prediction = model.predict(
|
| 12 |
-
return prediction[0]
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
fn=predict,
|
| 17 |
inputs=[
|
| 18 |
gr.Number(label="Feature 1"),
|
|
@@ -20,9 +20,10 @@ demo = gr.Interface(
|
|
| 20 |
gr.Number(label="Feature 3")
|
| 21 |
],
|
| 22 |
outputs="text",
|
| 23 |
-
title="
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
-
# Run
|
| 27 |
if __name__ == "__main__":
|
| 28 |
-
|
|
|
|
| 1 |
import joblib
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
+
import gradio as gr
|
| 4 |
|
| 5 |
+
# Load your trained model
|
| 6 |
model = joblib.load("model.joblib")
|
| 7 |
|
| 8 |
+
# Define the prediction function
|
| 9 |
+
def predict(input1, input2, input3):
|
| 10 |
+
inputs = np.array([[input1, input2, input3]])
|
| 11 |
+
prediction = model.predict(inputs)
|
| 12 |
+
return str(prediction[0]) # Convert to string for display
|
| 13 |
|
| 14 |
+
# Build the Gradio interface
|
| 15 |
+
interface = gr.Interface(
|
| 16 |
fn=predict,
|
| 17 |
inputs=[
|
| 18 |
gr.Number(label="Feature 1"),
|
|
|
|
| 20 |
gr.Number(label="Feature 3")
|
| 21 |
],
|
| 22 |
outputs="text",
|
| 23 |
+
title="Datathon Model Predictor",
|
| 24 |
+
description="Enter 3 features to get prediction from the deployed model."
|
| 25 |
)
|
| 26 |
|
| 27 |
+
# Run the app
|
| 28 |
if __name__ == "__main__":
|
| 29 |
+
interface.launch()
|