shamimjony1000 commited on
Commit
08a822f
·
verified ·
1 Parent(s): f1fd2ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -29,6 +29,13 @@ def main():
29
 
30
  uploaded_file = st.file_uploader('Upload an MRI image...', type=['jpg', 'png', 'jpeg'])
31
 
 
 
 
 
 
 
 
32
  if uploaded_file is not None:
33
  predicted_class = predict_image_class(uploaded_file)
34
 
@@ -37,25 +44,22 @@ def main():
37
  st.markdown(f"<div style='text-align: center; font-size: 30px;'>Predicted Alzheimer's stage is: <b>{class_names[predicted_class]}</b></div>", unsafe_allow_html=True)
38
  st.image(uploaded_file, use_column_width=False, width=300)
39
  else:
40
- # Display four example images if no image is uploaded
41
- example_images = ["mild_468_0_4983.jpg", "moderate_2_0_72.jpg", "non_61.jpg", "verymild_37_0_2606.jpg"]
42
- col1, col2, col3, col4 = st.columns(4)
43
-
44
- with col1:
45
- image1 = Image.open(example_images[0])
46
- st.image(image1, caption="Example 1", use_column_width=True)
 
 
47
 
48
- with col2:
49
- image2 = Image.open(example_images[1])
50
- st.image(image2, caption="Example 2", use_column_width=True)
51
 
52
- with col3:
53
- image3 = Image.open(example_images[2])
54
- st.image(image3, caption="Example 3", use_column_width=True)
55
 
56
- with col4:
57
- image4 = Image.open(example_images[3])
58
- st.image(image4, caption="Example 4", use_column_width=True)
59
 
60
  if __name__ == '__main__':
61
  main()
 
29
 
30
  uploaded_file = st.file_uploader('Upload an MRI image...', type=['jpg', 'png', 'jpeg'])
31
 
32
+ example_images = {
33
+ "MILD DEMENTED": "mild_468_0_4983.jpg",
34
+ "MODERATE DEMENTED": "moderate_2_0_72.jpg",
35
+ "NON DEMENTED": "non_61.jpg",
36
+ "VERY MILD DEMENTED": "verymild_37_0_2606.jpg"
37
+ }
38
+
39
  if uploaded_file is not None:
40
  predicted_class = predict_image_class(uploaded_file)
41
 
 
44
  st.markdown(f"<div style='text-align: center; font-size: 30px;'>Predicted Alzheimer's stage is: <b>{class_names[predicted_class]}</b></div>", unsafe_allow_html=True)
45
  st.image(uploaded_file, use_column_width=False, width=300)
46
  else:
47
+ st.write("Or select an example image below:")
48
+ selected_example = st.selectbox("Select an example image:", list(example_images.keys()))
49
+
50
+ if selected_example:
51
+ example_image_path = example_images[selected_example]
52
+ example_image = Image.open(example_image_path)
53
+
54
+ # Display the selected example image
55
+ st.image(example_image, caption=selected_example, use_column_width=True)
56
 
57
+ # Predict based on the selected example image
58
+ predicted_class = predict_image_class(example_image_path)
 
59
 
60
+ class_names = ["MILD DEMENTED", "MODERATE DEMENTED", "NON DEMENTED", "VERY MILD DEMENTED"]
 
 
61
 
62
+ st.markdown(f"<div style='text-align: center; font-size: 30px;'>Predicted Alzheimer's stage is: <b>{class_names[predicted_class]}</b></div>", unsafe_allow_html=True)
 
 
63
 
64
  if __name__ == '__main__':
65
  main()