Manith Marapperuma commited on
Commit
f076585
·
1 Parent(s): 6cceda6
Files changed (4) hide show
  1. app.py +26 -0
  2. chest_xray.h5 +3 -0
  3. requirements.txt +4 -0
  4. streamlit.py +31 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from keras.models import load_model
2
+ from keras.preprocessing import image
3
+ from keras.applications.vgg16 import preprocess_input # import the model`s skeleton
4
+ import numpy as np
5
+ import tensorflow as tf
6
+
7
+ model=load_model('chest_xray.h5')
8
+
9
+ #load the test image
10
+ #tf.keras.utils.load_img
11
+ img=tf.keras.utils.load_img('image.jpeg',target_size=(224,224))
12
+
13
+ x=tf.keras.preprocessing.image.img_to_array(img) # image as a numpy array
14
+
15
+ x=np.expand_dims(x, axis=0)
16
+
17
+ img_data=preprocess_input(x) # organize for the prediction
18
+
19
+ classes=model.predict(img_data)
20
+
21
+ result=int(classes[0][0])
22
+
23
+ if result== 0:
24
+ print("Person is Affected By PNEUMONIA")
25
+ else:
26
+ print("Result is Normal")
chest_xray.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5292242f3784a552b74a9c9c4c2b7409b91e710a1695ea7e80ac3408b67a2d3a
3
+ size 59545056
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ keras
4
+ numpy
streamlit.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from keras.models import load_model
3
+ from keras.preprocessing import image
4
+ from keras.applications.vgg16 import preprocess_input
5
+ import numpy as np
6
+ import tensorflow as tf
7
+
8
+ # Set the title of the web app
9
+ st.title('Pneumonia Detection Using VGG16')
10
+
11
+ st.text("Coded by Manith Jayaba")
12
+
13
+ # Load the Keras model
14
+ model = load_model('chest_xray.h5')
15
+
16
+ # Create a file uploader for the test image
17
+ uploaded_file = st.file_uploader("Choose an image...", type="jpg")
18
+
19
+ # Perform the prediction when an image is uploaded
20
+ if uploaded_file is not None:
21
+ img = tf.keras.utils.load_img(uploaded_file, target_size=(224, 224))
22
+ x = tf.keras.preprocessing.image.img_to_array(img)
23
+ x = np.expand_dims(x, axis=0)
24
+ img_data = preprocess_input(x)
25
+ classes = model.predict(img_data)
26
+ result = int(classes[0][0])
27
+ if result == 0:
28
+ st.write("Person is Affected By PNEUMONIA")
29
+ else:
30
+ st.write("Result is Normal")
31
+ st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)