File size: 742 Bytes
cda6b4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app_iris.py

import streamlit as st
import onnxruntime as rt
import numpy as np

# Load the trained ONNX model
sess = rt.InferenceSession("random_forest_iris.onnx")

st.title("Iris Prediction with Random Forest")

# Input features
sepal_length = st.slider("Sepal Length", 0.0, 10.0, 5.0)
sepal_width = st.slider("Sepal Width", 0.0, 10.0, 3.5)
petal_length = st.slider("Petal Length", 0.0, 10.0, 2.5)
petal_width = st.slider("Petal Width", 0.0, 10.0, 1.0)

input_features = [sepal_length, sepal_width, petal_length, petal_width]

# Predict
if st.button("Predict"):
    input_array = np.array([input_features], dtype=np.float32)
    pred_onnx = sess.run(None, {'float_input': input_array})
    st.write(f"Predicted class: {pred_onnx[0][0]}")