Testin1 / app.py
YeBhoneLin10's picture
Upload app.py
3a48f05 verified
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)