-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
41 lines (34 loc) · 1.28 KB
/
app.py
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
38
39
40
41
import streamlit as st
from PIL import Image
import numpy as np
from keras.models import load_model
from keras.preprocessing.image import img_to_array
# Load the trained model
model = load_model('model.hd5')
image_size = (64, 64)
def preprocess_image(image):
# Convert the image to the required size and format
img = image.resize(image_size)
img_array = img_to_array(img)
img_array = np.expand_dims(img_array, axis=0) / 255.0
return img_array
def main():
st.title("Diabetic Retinopathy Detection App")
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
if uploaded_file is not None:
# Display the uploaded image
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", width=200)
# Preprocess the image for prediction
processed_image = preprocess_image(image)
# Make prediction
prediction = model.predict(processed_image)
probability = prediction[0][0]
# Display the prediction result
st.subheader("Prediction Result:")
if probability > 0.4:
st.success("Diabetic Retinopathy Detected!")
else:
st.success("No Diabetic Retinopathy Detected!")
if __name__ == "__main__":
main()