|
|
import streamlit as st
|
|
|
import streamlit.web.cli as stcli
|
|
|
import tensorflow as tf
|
|
|
import numpy as np
|
|
|
from PIL import Image
|
|
|
|
|
|
IMAGE_SIZE = 256
|
|
|
|
|
|
|
|
|
model = tf.keras.models.load_model('my_model.h5')
|
|
|
|
|
|
|
|
|
class_labels = ['Mild', 'Moderate', 'No_DR', 'Proliferate_DR', 'Severe']
|
|
|
|
|
|
|
|
|
def predict(image):
|
|
|
|
|
|
image = tf.image.resize(image, (IMAGE_SIZE, IMAGE_SIZE))
|
|
|
image = np.expand_dims(image, axis=0)
|
|
|
|
|
|
|
|
|
predictions = model.predict(image)
|
|
|
confidence = np.max(predictions)
|
|
|
predicted_class = class_labels[np.argmax(predictions)]
|
|
|
|
|
|
return predicted_class, float(confidence)
|
|
|
|
|
|
|
|
|
|
|
|
st.title("Early Diabetic Retinopathy Detection")
|
|
|
st.write("Upload an image and get the predicted class along with confidence score.")
|
|
|
|
|
|
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
|
|
|
|
if uploaded_file is not None:
|
|
|
image = Image.open(uploaded_file)
|
|
|
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
|
|
st.write("")
|
|
|
st.write("Classifying...")
|
|
|
|
|
|
predicted_class, confidence = predict(image)
|
|
|
|
|
|
st.write(f"Predicted Class: {predicted_class}")
|
|
|
st.write(f"Confidence: {confidence:.2f}")
|
|
|
|