YeBhoneLin10 commited on
Commit
3fa0334
·
verified ·
1 Parent(s): 7f7b21b

Upload 2 files

Browse files
Files changed (2) hide show
  1. main.py +31 -0
  2. model.pkl +3 -0
main.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)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b5bafc94b2a5cce583143571238404c3332de71d8b1e4dc20ef8ad6f4e103f4
3
+ size 993