Spaces:
Runtime error
Runtime error
# Import library | |
import streamlit as st | |
import numpy as np | |
from tensorflow import keras | |
from PIL import Image | |
# Load model | |
model = keras.models.load_model('model_tuned.hdf5') | |
st.header('Lung X-Ray Prediction') | |
st.write('Please Upload Your X-Ray Image') | |
# Upload Image | |
uploaded_file = st.file_uploader("", type=["jpg", "jpeg", "png"]) | |
# Show Uploaded Image | |
if uploaded_file is not None: | |
image = Image.open(uploaded_file).convert('RGB') | |
st.subheader('This Is Your X-Ray Image') | |
st.image(image, width=200) | |
st.write('Push This Button To Predict') | |
if st.button('Predict'): | |
# resize uploaded image | |
inf = image.resize((224,224)) | |
# make into array | |
inf = np.asarray(inf) | |
# expands dims to tensor | |
inf = np.expand_dims(inf, axis = 0) | |
# define label | |
label = ['Covid', 'Normal', 'Pneumonia'] | |
# Make the prediction | |
prediction = model.predict(inf) | |
prediction = label[np.argmax(prediction)] | |
st.subheader(f"This X-Ray Images Has {prediction} Condition") | |