Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected the code according to the newer version of tenserflow and updated the requirements.txt file #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions glaucoma_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,50 @@
from PIL import Image, ImageOps
import numpy as np

st.set_option('deprecation.showfileUploaderEncoding', False)
# Set Streamlit option to suppress deprecation warning
# st.set_option('deprecation.showfileUploaderEncoding', False)

# @st.cache(suppress_st_warning=True,allow_output_mutation=True)
# Function to preprocess image and make predictions
def import_and_predict(image_data, model):
image = ImageOps.fit(image_data, (100,100),Image.ANTIALIAS)
# Resize image to the required input size of the model
image = ImageOps.fit(image_data, (100, 100), Image.Resampling.LANCZOS)
image = image.convert('RGB')
image = np.asarray(image)
st.image(image, channels='RGB')
image = (image.astype(np.float32) / 255.0)
img_reshape = image[np.newaxis,...]

# Normalize the image
image = image.astype(np.float32) / 255.0
img_reshape = np.expand_dims(image, axis=0)

# Prediction
prediction = model.predict(img_reshape)
return prediction

# Load the model (ensure 'my_model2.h5' is compatible with the current TensorFlow version)
model = tf.keras.models.load_model('my_model2.h5')

# Streamlit interface
st.write("""
# ***Glaucoma detector***
"""
)
# ***Glaucoma Detector***
This is a simple image classification web app to predict glaucoma through fundus image of the eye.
""")

st.write("This is a simple image classification web app to predict glaucoma through fundus image of eye")

file = st.file_uploader("Please upload an image(jpg) file", type=["jpg"])
file = st.file_uploader("Please upload an image (jpg) file", type=["jpg"])

# Check if a file has been uploaded
if file is None:
st.text("You haven't uploaded a jpg image file")
st.text("You haven't uploaded an image file.")
else:
# Open image
imageI = Image.open(file)

# Make predictions
prediction = import_and_predict(imageI, model)
pred = prediction[0][0]
if(pred > 0.5):
st.write("""
## **Prediction:** You eye is Healthy. Great!!
"""
)

# Display results
if pred > 0.5:
st.write("## **Prediction:** Your eye appears healthy. Great!")
st.balloons()
else:
st.write("""
## **Prediction:** You are affected by Glaucoma. Please consult an ophthalmologist as soon as possible.
"""
)
st.write("## **Prediction:** You may be affected by Glaucoma. Please consult an ophthalmologist.")
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tensorflow==2.3.0
streamlit==0.81.1
tensorflow==2.17.0
pillow==8.3.2
numpy==1.16.5
streamlit==0.81.1