Spaces:
Build error
Build error
Alok Bhattarai
commited on
Commit
·
336a3c8
1
Parent(s):
50b0082
updates
Browse files
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 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 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 |
|