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

Fixed Brain tumor code #136

Merged
merged 1 commit into from
Oct 13, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,48 @@

@st.cache_resource
def load_model():
model = tf.keras.models.load_model("src/apps/pages/models/HealthCareModels/BrainTumorModel/brain_tumor_test.keras")
return model
model = tf.keras.models.load_model("src/apps/pages/models/HealthCareModels/BrainTumorModel/brain_tumor_test.keras")
return model

def get_mri():
img = st.file_uploader("Upload here",type=["jpg","jpeg"])
codn = False
data = []
if img is not None:
st.image(img,width=420,caption="Uploaded Img")
data = Image.open(img).convert("RGB" )
data = data.resize((64,64))
data = np.asarray(data)
data = np.expand_dims(data,axis=0)
codn = True

return codn,data
img = st.file_uploader("Upload here", type=["jpg", "jpeg"])
codn = False
data = []
if img is not None:
st.image(img, width=420, caption="Uploaded Img")
data = Image.open(img).convert("RGB")
data = data.resize((64, 64))
data = np.asarray(data)
data = np.expand_dims(data, axis=0)
codn = True

return codn, data

def do_test(img):
model = load_model()
res = np.argmax(model.predict(img))
return res
model = load_model()
res = np.argmax(model.predict(img))
return res

def brainTumorModel():
st.write("Please Upload MRI Scan of Brain")
codn,img = get_mri()
res = None

if codn!=False:
res = do_test(img)

if res!=None:
if res == 0:
st.error(f'Hi {st.session_state.name},\nYou are diagnosed with Glioma.\nPlease consult a doctor.')
Speak(f'Hi {st.session_state.name},You are diagnosed with Glioma. Please consult a doctor.')
elif res == 1:
st.error(f'Hi {st.session_state.name},\nYou are diagnosed with Meningioma.\nPlease consult a doctor.')
Speak(f'Hi {st.session_state.name},You are diagnosed with Meningioma. Please consult a doctor.')
elif res == 2:
st.success(f'Congrats {st.session_state.name}, You are not diagnosed with brain tumor.')
Speak(f'Congrats {st.session_state.name}, You are not diagnosed with brain tumor.')
elif res == 3:
st.error(f'Hi {st.session_state.name},\nYou are diagnosed with Pituitary tumor. Please consult a doctor.')
Speak(f'Hi {st.session_state.name},You are diagnosed with Pituitary tumor. Please consult a doctor.')
st.write("Please Upload MRI Scan of Brain")
codn, img = get_mri()
res = None

if codn:
res = do_test(img)

if res is not None:
if res == 0:
st.error("Hi User, You are diagnosed with Glioma. Please consult a doctor.")
Speak("Hi User, You are diagnosed with Glioma. Please consult a doctor.")
elif res == 1:
st.error("Hi User, You are diagnosed with Meningioma. Please consult a doctor.")
Speak("Hi User, You are diagnosed with Meningioma. Please consult a doctor.")
elif res == 2:
st.success("Congrats User, You are not diagnosed with a brain tumor.")
Speak("Congrats User, You are not diagnosed with a brain tumor.")
elif res == 3:
st.error("Hi User, You are diagnosed with Pituitary tumor. Please consult a doctor.")
Speak("Hi User, You are diagnosed with Pituitary tumor. Please consult a doctor.")

codn = False