annapurnapadmaprema-ji commited on
Commit
6312f5a
1 Parent(s): c2afbec

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +44 -0
  2. cnn_tumor2.h5 +3 -0
  3. styles.css +18 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import numpy as np
4
+ import tensorflow as tf
5
+
6
+
7
+
8
+ def load_model():
9
+ model = tf.keras.models.load_model('cnn_tumor2.h5')
10
+ return model
11
+
12
+ model = load_model()
13
+
14
+
15
+ def preprocess_image(image):
16
+ image = image.resize((128,128))
17
+ image = np.array(image) / 255.0
18
+ image = np.expand_dims(image, axis=0)
19
+ return image
20
+
21
+
22
+ def predict_tumor(image):
23
+ predictions = model.predict(image)
24
+ if predictions[0] > 0.5:
25
+ return "Tumorous"
26
+ else:
27
+ return "Non-tumorous"
28
+
29
+ with open("styles.css") as f:
30
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
31
+ st.title("Tumor Detection using CNN")
32
+
33
+
34
+ uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "jpeg", "png"])
35
+
36
+
37
+ if uploaded_file is not None:
38
+ image = Image.open(uploaded_file)
39
+ resized_image = image.resize((300, 200))
40
+ st.image(resized_image, caption="Uploaded Image")
41
+
42
+ processed_image = preprocess_image(image)
43
+ result = predict_tumor(processed_image)
44
+ st.info(f"Prediction: {result}")
cnn_tumor2.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79887365bf9fbb0506200b86a18ae7d473132944f31662c61e192bea3da19220
3
+ size 391807368
styles.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .stApp {
2
+ background-image: url('https://i.postimg.cc/9FY4zK10/Fatehput-Sikiri-Buland-Darwaza-gate-2010.jpg');
3
+ background-size: cover;
4
+ background-position: center;
5
+ background-repeat: no-repeat;
6
+ .glass {
7
+ background: rgba(255, 255, 255, 0.1); /* Translucent background */
8
+ backdrop-filter: blur(10px); /* Blurring effect */
9
+ border-radius: 10px; /* Rounded corners */
10
+ padding: 10px;
11
+ color: #ffffff; /* Text color */
12
+ font-weight: bold; /* Bold text */
13
+ }
14
+
15
+
16
+
17
+
18
+ }