|
import streamlit as st |
|
import pandas as pd |
|
import numpy as np |
|
import tensorflow as tf |
|
from tensorflow.keras.applications.resnet50 import preprocess_input |
|
from tensorflow.keras.preprocessing.image import load_img, img_to_array |
|
|
|
|
|
st.header('X-ray Chest Syptoms Classification') |
|
|
|
|
|
image_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) |
|
|
|
if image_file is not None: |
|
|
|
def preprocess_image(image_file): |
|
image = load_img(image_file, target_size=(224, 224)) |
|
image = img_to_array(image) |
|
image = preprocess_input(image) |
|
image = np.expand_dims(image, axis=0) |
|
return image |
|
|
|
preprocessed_image = preprocess_image(image_file) |
|
|
|
|
|
model = tf.keras.models.load_model('./model.hdf5') |
|
|
|
if preprocessed_image is not None: |
|
|
|
prediction = model.predict(preprocessed_image) |
|
predicted_class = np.argmax(prediction) |
|
class_labels = ['COVID19', 'NORMAL', 'PNEUMONIA', 'TURBERCULOSIS'] |
|
|
|
st.subheader("Prediction:") |
|
st.write(f"Predicted Class: {class_labels[predicted_class]}") |
|
st.write(f"Confidence: {prediction[0][predicted_class]:.2f}") |
|
|