forked from raminmohammadi/MLOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
executable file
·27 lines (24 loc) · 1.09 KB
/
streamlit_app.py
File metadata and controls
executable file
·27 lines (24 loc) · 1.09 KB
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
import streamlit as st
import requests
import os
st.title('IRIS Prediction')
sepal_length = st.number_input('Sepal Length', min_value=0.0, max_value=10.0, step=0.1)
sepal_width = st.number_input('Sepal Width', min_value=0.0, max_value=10.0, step=0.1)
petal_length = st.number_input('Petal Length', min_value=0.0, max_value=10.0, step=0.1)
petal_width = st.number_input('Petal Width', min_value=0.0, max_value=10.0, step=0.1)
if st.button('Predict'):
data = {
'sepal_length': sepal_length,
'sepal_width': sepal_width,
'petal_length': petal_length,
'petal_width': petal_width
}
try:
response = requests.post('https://iris-app-155173250771.us-central1.run.app/predict', json=data)
if response.status_code == 200:
prediction = response.json()['prediction']
st.success(f'Predicted species: {prediction}')
else:
st.error(f'Error occurred during prediction. Status code: {response.status_code}')
except requests.exceptions.RequestException as e:
st.error(f'Error occurred during prediction: {str(e)}')