-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.py
93 lines (70 loc) · 3.83 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
"""app.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1yYnGyKzgTxdPiHOeI5FQS-2PTO2Vranr
"""
import streamlit as st
import tensorflow.keras
from PIL import Image, ImageOps
import numpy as np
def main():
primaryColor="black"
backgroundColor="pink"
st.set_page_config(
page_title="BreastCancerDetector",page_icon= "🎗️")
st.markdown("<h1 style='text-align: center; color: #f8e7ed; font-size:65px; font-family: Copperplatec'>Breast Cancer Detector</h1>", unsafe_allow_html=True)
st.markdown("<h4 style='text_align: center; color: white;'>This program is designed to predict two severity of abnormalities associated with breast cancer cells: benign and malignant.</h4>", unsafe_allow_html=True)
st.image("app_pic.png", width=800)
image_input = st.file_uploader(label="Upload Breast Mammogram (PGM, PNG, JPG)",type=['pgm', 'png', 'jpg'])
detect = st.button("Detect Breast Cancer")
np.set_printoptions(suppress=True)
model = tensorflow.keras.models.load_model('Final_model.h5')
if image_input is not None:
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
image = Image.open(image_input, mode='r')
image = image.convert('RGB')
size = (224, 224)
image = ImageOps.fit(image, size, Image.ANTIALIAS)
image_array = np.asarray(image)
data[0] = image_array
size = st.slider("Adjust Image Size: ", 300, 1000)
st.image(image, width=size)
if detect:
prediction = model.predict(data)
class1 = prediction[0,0]
class2 = prediction[0,1]
if class1 > class2:
st.info(" **Benign Tumor** by {:.2f}%. Please visit [breastcancer.org](https://www.breastcancer.org/) for more information about your next step".format(class1 * 100) )
elif class2 > class1:
st.info(" **Malignant Tumor** by {:.2f}%. Please visit [breastcancer.org](https://www.breastcancer.org/) for more information about your next step ".format(class2 * 100))
else:
st.info("We encountered an ERROR. This should be temporary, please try again with a better quality image. Cheers!")
st.write("-----------------------------------------------------------")
st.markdown("<h3 style='text_align: center; color: #f8e7ed; font-size:40px; font-family: Copperplatec'>About Us</h3>",unsafe_allow_html=True)
st.markdown("<h5 style='text_align: center; color: #f8e7ed; font-family: Copperplatec'><i>This project was made by ITI-AI Pro students with the supervision of Eng. Kareem Negm, to help people detect breast cancer</i</h5>",unsafe_allow_html=True)
col1, col2, col3= st.columns(3)
with col1:
st.subheader("***Aya Shehata***")
st.image("https://static.streamlit.io/examples/cat.jpg")
st.write("check out [LinkedIn](https://www.linkedin.com/in/aya-shehata-0a455b1b6/)")
st.write("check out [Github](https://github.com/AyaShehata903)")
with col2:
st.subheader("***Omnia Mahdy***")
st.image("https://static.streamlit.io/examples/dog.jpg")
st.write("check out [LinkedIn](https://www.linkedin.com/in/omnia-imam)")
st.write("check out [Github](https://github.com/omnia-emam)")
with col3:
st.subheader("***Eng. Kareem Negm***")
st.image("https://avatars.githubusercontent.com/u/60659601?v=4")
st.write("check out [LinkedIn](https://www.linkedin.com/in/kareem-negm)")
st.write("check out [Github](https://github.com/Kareem-negm)")
if __name__ == '__main__':
main()
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)