Spaces:
Build error
Build error
Commit
·
bbecad4
1
Parent(s):
dcb4a07
Upload 7 files
Browse files- CNN_MODEL_0_96414.h5 +3 -0
- CNN_MODEL_0_9672.h5 +3 -0
- CNN_MODEL_0_9687.h5 +3 -0
- CNN_MODEL_0_9771.h5 +3 -0
- CNN_MODEL_0_9794.h5 +3 -0
- app.py +132 -0
- requirements.txt +0 -0
CNN_MODEL_0_96414.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9e9e6d4bb4156eb00a716b70b8ac5f304390d3aee5a59aa4747a3db81619a7e
|
| 3 |
+
size 216258760
|
CNN_MODEL_0_9672.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6f8eeb4eec8096f3aa72de497e7d3681a2dab1fed994aa5edc422f2ba3b9f28
|
| 3 |
+
size 141561592
|
CNN_MODEL_0_9687.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f26b5ff8e41202202bb8fdcab808437d481f608a5d79d1433e7dc7c697ac1718
|
| 3 |
+
size 237506200
|
CNN_MODEL_0_9771.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d26361c894bcc2dd650261aff82009a24b105aea9d0d19b6e6ff72b56ae8f22
|
| 3 |
+
size 304564232
|
CNN_MODEL_0_9794.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c92ab3fad88fc1c7fd4bf5d0c5662b83374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| 11 |
+
vggnet_19= keras.models.load_model("CNN_MODEL_0_9687.h5")
|
| 12 |
+
vggnet_16 = keras.models.load_model("CNN_MODEL_0_96414.h5")
|
| 13 |
+
resnet_152 = keras.models.load_model("CNN_MODEL_0_9794.h5")
|
| 14 |
+
mobilenet_v3= keras.models.load_model("CNN_MODEL_0_9771.h5")
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def check_accuracy(model,img_input):
|
| 18 |
+
y_pred = model.predict(img_input).argmax(axis=1)
|
| 19 |
+
prediction = model.predict(img_input)
|
| 20 |
+
if y_pred[0] == 0:
|
| 21 |
+
return "Target: glioma_tumor",prediction.max()
|
| 22 |
+
elif y_pred[0] == 1:
|
| 23 |
+
return "Target: meningioma_tumor",prediction.max()
|
| 24 |
+
elif y_pred[0] == 2:
|
| 25 |
+
return "Target: no_tumor",prediction.max()
|
| 26 |
+
else:
|
| 27 |
+
return "Target: pituitary_tumor",prediction.max()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
with st.container():
|
| 32 |
+
file = st.file_uploader("Upload the MRI Image")
|
| 33 |
+
if file is not None:
|
| 34 |
+
print(file)
|
| 35 |
+
save_image_path = "./upload_images/"+file.name
|
| 36 |
+
with open(save_image_path,"wb") as f:
|
| 37 |
+
f.write(file.getbuffer())
|
| 38 |
+
img = cv2.imread(save_image_path)
|
| 39 |
+
|
| 40 |
+
col1,col2 = st.columns(2)
|
| 41 |
+
with st.container():
|
| 42 |
+
if file is not None:
|
| 43 |
+
with col1:
|
| 44 |
+
st.write("Original Image:")
|
| 45 |
+
st.image(file)
|
| 46 |
+
with col2:
|
| 47 |
+
st.write("Processed Image:")
|
| 48 |
+
st.image(cv2.resize(img,(224,224)))
|
| 49 |
+
else:
|
| 50 |
+
st.error("First upload image")
|
| 51 |
+
|
| 52 |
+
with st.container():
|
| 53 |
+
if file is not None:
|
| 54 |
+
img = cv2.resize(img,(224,224))
|
| 55 |
+
img_input = img.reshape((1,224,224,3))
|
| 56 |
+
vgg19,v19 = check_accuracy(vggnet_19,img_input)
|
| 57 |
+
vgg16,v16 = check_accuracy(vggnet_16,img_input)
|
| 58 |
+
resnet,r152 = check_accuracy(resnet_152,img_input)
|
| 59 |
+
mobilenet,mv3 = check_accuracy(mobilenet_v3,img_input)
|
| 60 |
+
st.subheader(vgg19+" for"+ " VGGNET-19")
|
| 61 |
+
st.write("accuracy of the image",v19)
|
| 62 |
+
st.subheader(vgg16+" for"+ " VGGNET-16")
|
| 63 |
+
st.write("accuracy of the image",v16)
|
| 64 |
+
st.subheader(resnet+" for"+ " RESNET-152")
|
| 65 |
+
st.write("accuracy of the image",r152)
|
| 66 |
+
st.subheader(mobilenet+" for"+ " MOBILENET-V3")
|
| 67 |
+
st.write("accuracy of the image",mv3)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# st.sidebar.title("Choose the Model:")
|
| 81 |
+
# option = st.sidebar.selectbox("Select model",["model1","model2"])
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
# if option == "model1":
|
| 85 |
+
# st.header("Model 1")
|
| 86 |
+
# file = st.file_uploader("Upload the MRI Image")
|
| 87 |
+
# if file is not None:
|
| 88 |
+
# print(file)
|
| 89 |
+
# save_image_path = "./upload_images/"+file.name
|
| 90 |
+
# with open(save_image_path,"wb") as f:
|
| 91 |
+
# f.write(file.getbuffer())
|
| 92 |
+
# img = cv2.imread(save_image_path)
|
| 93 |
+
# img = cv2.resize(img,(250,250))
|
| 94 |
+
# img_input = img.reshape((1,250,250,3))
|
| 95 |
+
# y_pred = model1.predict(img_input).argmax(axis=1)
|
| 96 |
+
|
| 97 |
+
# if y_pred[0] == 0:
|
| 98 |
+
# st.write("Target: glioma_tumor")
|
| 99 |
+
# elif y_pred[0] == 1:
|
| 100 |
+
# st.write("Target: meningioma_tumor")
|
| 101 |
+
# elif y_pred[0] == 2:
|
| 102 |
+
# st.write("Target: no_tumor")
|
| 103 |
+
# else:
|
| 104 |
+
# st.write("Target: pituitary_tumor")
|
| 105 |
+
|
| 106 |
+
# else:
|
| 107 |
+
# st.warning("Not Entered image")
|
| 108 |
+
|
| 109 |
+
# if option == "model2":
|
| 110 |
+
# st.header("Model 2")
|
| 111 |
+
# file = st.file_uploader("Upload the MRI Image")
|
| 112 |
+
# if file is not None:
|
| 113 |
+
# print(file)
|
| 114 |
+
# save_image_path = "./upload_images/"+file.name
|
| 115 |
+
# with open(save_image_path,"wb") as f:
|
| 116 |
+
# f.write(file.getbuffer())
|
| 117 |
+
# img = cv2.imread(save_image_path)
|
| 118 |
+
# img = cv2.resize(img,(250,250))
|
| 119 |
+
# img_input = img.reshape((1,250,250,3))
|
| 120 |
+
# y_pred = model2.predict(img_input).argmax(axis=1)
|
| 121 |
+
|
| 122 |
+
# if y_pred[0] == 0:
|
| 123 |
+
# st.write("Target: glioma_tumor")
|
| 124 |
+
# elif y_pred[0] == 1:
|
| 125 |
+
# st.write("Target: meningioma_tumor")
|
| 126 |
+
# elif y_pred[0] == 2:
|
| 127 |
+
# st.write("Target: no_tumor")
|
| 128 |
+
# else:
|
| 129 |
+
# st.write("Target: pituitary_tumor")
|
| 130 |
+
|
| 131 |
+
# else:
|
| 132 |
+
# st.warning("Not Entered image")
|
requirements.txt
ADDED
|
Binary file (2.88 kB). View file
|
|
|