File size: 979 Bytes
5b3feb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
import streamlit as st
import requests
import json
from io import BytesIO

st.title('COVID-19 Prediction')
st.subheader('Provide an X-ray of lungs and check if you have covid-19, or any other desease or your normal.')

# Take image input
img_file_buffer = st.file_uploader("Upload your chest X-ray")

if img_file_buffer is not None:
    # Retrive the file value
    img_bytes = img_file_buffer.getvalue()

    # Create a payload
    files = {"x_ray_image": BytesIO(img_bytes)}

    URL = "http://127.0.0.1:8000/get_prediction"

    with st.spinner("Waiting for model response..."):
        st.write("Came in spinner")
        resp = requests.post(
            URL, 
            files = files,
            )
        
        st.write("Executed response")

        if resp._content is not None:
            resp_data = json.loads(resp._content.decode('utf-8'))
            st.write(resp_data)
        else:
            st.write(resp.__dict__)