Spaces:
Runtime error
Runtime error
File size: 1,741 Bytes
2e03848 d474b29 0c0194f 69e8adc d474b29 c7b5f81 4f1bd87 80fafc0 badf1d7 6300a71 80fafc0 6300a71 80fafc0 badf1d7 80fafc0 6300a71 80fafc0 6300a71 eff1875 6300a71 eff1875 6300a71 eff1875 b16d5d3 82aa9d7 d3194d2 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import joblib
import pandas as pd
import streamlit as st
from PIL import Image
image = Image.open('iris.png')
image_setosa = Image.open('Irissetosa.jpg')
image_virginica = Image.open('iris_virginica.jpg')
image_versicolor = Image.open('versicolor.jpg')
st.image(image, caption='Iris')
model = joblib.load('model_XG.joblib')
def main():
st.title("Iris's Class")
with st.form("questionaire"):
sepal_length = st.slider("Sepal_length(cm)", 0.0, 10.0, 0.1)
sepal_width = st.slider("Sepal_width(cm)", 0.0, 10.0, 0.1)
petal_length = st.slider("Petal_length(cm)", 0.0, 10.0, 0.1)
petal_width = st.slider("Petal_width(cm)", 0.0, 10.0, 0.1)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict class")
if clicked:
result=model.predict(pd.DataFrame({"sepal.length": [sepal_length],
"sepal.width": [sepal_width],
"petal.length": [petal_length],
"petal.width": [petal_width]}))
# Show prediction
if result[0] == 0:
result = "Iris-setosa"
st.image(image_setosa, caption='Iris Setosa', width = 350)
elif result[0] == 1:
result = "Iris-versicolor"
st.image(image_versicolor, caption='Iris Versicolor', width = 350)
else:
result = "Iris-virginica"
st.image(image_virginica, caption='Iris Virginica', width = 350)
st.write(f"Your predicted class is {result}")
if __name__ == '__main__':
main()
|