File size: 1,231 Bytes
3a48f05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
import pickle

def model(sl,sw,pl,pw):
  sepal_length = float()
  sepal_width = float()
  petal_length = float()
  petal_width = float()
  dataframe = pd.DataFrame({"sepal length (cm)":[sepal_length],"sepal width (cm)":[sepal_width],'petal length (cm)':[petal_length],'petal width (cm)':[petal_width]})
  with open('/content/model.pkl', 'rb') as file:
    loaded_model = pickle.load(file)
    output = loaded_model.predict(dataframe)
    if output == 0:
        return"The output class is setosa"
    elif output == 1:
        return"The output class is versicolor"
    elif output == 2:
        return"The output class is virginica"

with gr.Blocks() as demo:
  with gr.Row():
    sepal_length = gr.Number(label="Sepal length (cm)", value=5.1)
    sepal_width = gr.Number(label="Sepal width (cm)", value=3.5)
    petal_length = gr.Number(label="Petal length (cm)", value=1.1)
    petal_width = gr.Number(label="Petal width (cm)", value=2.1)
  with gr.Row():
    outputs = gr.Textbox(label='Prediction')
    run = gr.Button(value="Prediction")

    run.click(model, inputs=[sepal_length, sepal_width, petal_length, petal_width], outputs=outputs)
demo.launch(debug=True, share=True)