Alok Bhattarai commited on
Commit
336a3c8
·
1 Parent(s): 50b0082
Files changed (1) hide show
  1. app.py +34 -34
app.py CHANGED
@@ -45,40 +45,40 @@ if uploaded_file is not None:
45
  file_bytes = BytesIO(uploaded_file.read())
46
  st.image(file_bytes,use_column_width=True,clamp = True)
47
 
48
- predict_button = st.button("ㅤㅤPredictㅤㅤ")
49
- if predict_button:
50
- img = cv2.imdecode(np.frombuffer(file_bytes.read(), np.uint8), 0)
51
- #img=np.array(file_bytes)
52
-
53
- if len(img.shape) == 2:
54
- img=cv2.cvtColor(img,cv2.COLOR_GRAY2RGB)
55
-
56
- img=cv2.resize(img,(176, 176))
57
- if img.max() > 1:
58
- img = img / 255.0
59
-
60
- img = np.expand_dims(img, axis=0)
61
- pred=model.predict(img)
62
- predict_val = np.argmax(pred, axis=1)
63
-
64
- if predict_val == 0:
65
- probability = pred[0][predict_val]
66
- st.write(f"Mildly Demented with prediction probability of {probability}")
67
-
68
- elif predict_val == 1:
69
- probability = pred[0][predict_val]
70
- st.write(f"Moderately Demented with prediction probability of {probability}")
71
-
72
- elif predict_val == 2:
73
- probability = pred[0][predict_val]
74
- st.write(f"Not Demented with prediction probability of {probability}")
75
-
76
- elif predict_val == 3:
77
- probability = pred[0][predict_val]
78
- st.write(f"Very Mildly Demented with prediction probability of {probability}")
79
-
80
- else:
81
- st.write("Error!")
82
 
83
 
84
 
 
45
  file_bytes = BytesIO(uploaded_file.read())
46
  st.image(file_bytes,use_column_width=True,clamp = True)
47
 
48
+ predict_button = st.button("ㅤㅤPredictㅤㅤ")
49
+ if predict_button:
50
+ img = cv2.imdecode(np.frombuffer(file_bytes.read(), np.uint8), 0)
51
+ #img=np.array(file_bytes)
52
+
53
+ if len(img.shape) == 2:
54
+ img=cv2.cvtColor(img,cv2.COLOR_GRAY2RGB)
55
+
56
+ img=cv2.resize(img,(176, 176))
57
+ if img.max() > 1:
58
+ img = img / 255.0
59
+
60
+ img = np.expand_dims(img, axis=0)
61
+ pred=model.predict(img)
62
+ predict_val = np.argmax(pred, axis=1)
63
+
64
+ if predict_val == 0:
65
+ probability = pred[0][predict_val]
66
+ st.warning(f"Mildly Demented with prediction probability of {probability}")
67
+
68
+ elif predict_val == 1:
69
+ probability = pred[0][predict_val]
70
+ st.warning(f"Moderately Demented with prediction probability of {probability}")
71
+
72
+ elif predict_val == 2:
73
+ probability = pred[0][predict_val]
74
+ st.warning(f"Not Demented with prediction probability of {probability}")
75
+
76
+ elif predict_val == 3:
77
+ probability = pred[0][predict_val]
78
+ st.warning(f"Very Mildly Demented with prediction probability of {probability}")
79
+
80
+ else:
81
+ st.warning("Error!")
82
 
83
 
84