gracialy commited on
Commit
46e8693
·
1 Parent(s): 32daf8f

add gradio

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -1,18 +1,18 @@
1
  import joblib
2
- import gradio as gr
3
  import numpy as np
 
4
 
5
- # Load the model
6
  model = joblib.load("model.joblib")
7
 
8
- # Define prediction function
9
- def predict(input1, input2, input3): # adjust based on your features
10
- X = np.array([[input1, input2, input3]])
11
- prediction = model.predict(X)
12
- return prediction[0]
13
 
14
- # Create Gradio interface
15
- demo = gr.Interface(
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="My Sklearn Model"
 
24
  )
25
 
26
- # Run Gradio app
27
  if __name__ == "__main__":
28
- demo.launch()
 
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()