Spaces:
Runtime error
Runtime error
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() | |