Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pickle
|
3 |
+
|
4 |
+
def model(sl,sw,pl,pw):
|
5 |
+
sepal_length = float()
|
6 |
+
sepal_width = float()
|
7 |
+
petal_length = float()
|
8 |
+
petal_width = float()
|
9 |
+
dataframe = pd.DataFrame({"sepal length (cm)":[sepal_length],"sepal width (cm)":[sepal_width],'petal length (cm)':[petal_length],'petal width (cm)':[petal_width]})
|
10 |
+
with open('/content/model.pkl', 'rb') as file:
|
11 |
+
loaded_model = pickle.load(file)
|
12 |
+
output = loaded_model.predict(dataframe)
|
13 |
+
if output == 0:
|
14 |
+
return"The output class is setosa"
|
15 |
+
elif output == 1:
|
16 |
+
return"The output class is versicolor"
|
17 |
+
elif output == 2:
|
18 |
+
return"The output class is virginica"
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
with gr.Row():
|
22 |
+
sepal_length = gr.Number(label="Sepal length (cm)", value=5.1)
|
23 |
+
sepal_width = gr.Number(label="Sepal width (cm)", value=3.5)
|
24 |
+
petal_length = gr.Number(label="Petal length (cm)", value=1.1)
|
25 |
+
petal_width = gr.Number(label="Petal width (cm)", value=2.1)
|
26 |
+
with gr.Row():
|
27 |
+
outputs = gr.Textbox(label='Prediction')
|
28 |
+
run = gr.Button(value="Prediction")
|
29 |
+
|
30 |
+
run.click(model, inputs=[sepal_length, sepal_width, petal_length, petal_width], outputs=outputs)
|
31 |
+
demo.launch(debug=True, share=True)
|