File size: 1,143 Bytes
10a92b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st 
import requests

API_URL='http://127.0.0.1:8000/prediction'

st.title("Iris Flower Predictor")
st.markdown("Enter the flower samples below")

sepal_length = st.number_input('Sepal_length',min_value=0.1,max_value=10.0,value=4.0)
sepal_width =st.number_input('sepal_width',min_value=0.1,max_value=10.1,value=5.0)
petal_length = st.number_input('Petal_legth',max_value=10.1,min_value=0.1,value=5.0)
petal_width = st.number_input('petal_width',max_value=10.1,min_value=0.1,value=4.0)

if st.button('predict Flower class'):
    input_data ={
        'sepal_length':sepal_length,
        'sepal_width': sepal_width,
        'petal_length': petal_length,
        'petal_width': petal_width
    }

    try:
        response = requests.post(API_URL,json=input_data)
        if response.status_code==200:
            predicition =response.json()
            st.success(f"prediction: {predicition['Predicted Class']}")

        else:
            st.error(f"Error: {response.status_code}-{response.txt}") 


    except Exception as e:
        st.error(f'An error occcurred:{e}')