File size: 760 Bytes
0463385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84e20b2
0463385
 
 
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
import requests
import streamlit as st

st.title("CIFAR10 Prediction")

HOST = "http://localhost:8000"

uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
    with st.container(height=300):
        st.image(uploaded_file, caption='Uploaded Image', use_column_width=True)

    if st.button('Predict'):
        # Send image to FastAPI endpoint
        files = {'file': uploaded_file}
        response = requests.post(f"{HOST}/upload_image_for_inference", files=files)

        if response.status_code == 200:
            result = response.json()
            st.header(f"Predicted class: {result['predicted_class']}")
        else:
            st.error("Error processing image. Please try again.")