Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from sklearn.tree import DecisionTreeRegressor
|
| 4 |
+
import pickle
|
| 5 |
+
# from joblib import load
|
| 6 |
+
|
| 7 |
+
tree_model = pickle.load(open('/content/weld-depth-and-width-flask/tree_model.pkl', 'rb'))
|
| 8 |
+
# tree_model = load('tree_model.joblib')
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def predict(IW, IF, VW, FP):
|
| 12 |
+
params = [[float(IW), float(IF), float(VW), float(FP)]]
|
| 13 |
+
prediction = np.round(tree_model.predict(params), 2)
|
| 14 |
+
depth, width = prediction[0]
|
| 15 |
+
print(depth, width)
|
| 16 |
+
return depth, width
|
| 17 |
+
|
| 18 |
+
input1 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 1")
|
| 19 |
+
input2 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 2")
|
| 20 |
+
input3 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 3")
|
| 21 |
+
input4 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 4")
|
| 22 |
+
|
| 23 |
+
output1 = gr.outputs.Textbox(label="Output")
|
| 24 |
+
output2 = gr.outputs.Textbox(label="Output")
|
| 25 |
+
interface = gr.Interface(fn=predict, inputs=[input1, input2], outputs=[output1, output2])
|
| 26 |
+
interface.launch(debug=True, share=True)
|