samithcs commited on
Commit
d6629cd
·
verified ·
1 Parent(s): 38bd775

Upload 5 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ bgs/bg5_blur.png filter=lfs diff=lfs merge=lfs -text
37
+ bgs/bg5.png filter=lfs diff=lfs merge=lfs -text
38
+ model/pneumonia_classifier.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from PIL import Image
4
+ import numpy as np
5
+ import cv2
6
+ from keras.models import load_model
7
+ from util import set_background
8
+
9
+ bg = cv2.imread('./bgs/bg5.png')
10
+
11
+ blurred_bg = cv2.GaussianBlur(bg, (15, 15), 0)
12
+
13
+ cv2.imwrite('./bgs/bg5_blur.png', blurred_bg)
14
+
15
+ # Set background
16
+ set_background('./bgs/bg5_blur.png')
17
+
18
+ # Set title and header
19
+ st.title('🩺 Pneumonia Classifier Application')
20
+ st.header('Upload a Chest X-ray Image')
21
+
22
+ # Upload file
23
+ file = st.file_uploader(
24
+ "Upload a chest X-ray image",
25
+ type=['jpeg', 'jpg', 'png'],
26
+ label_visibility="visible"
27
+ )
28
+
29
+ # Load model
30
+ model_path = os.path.join(os.path.dirname(__file__), 'model', 'pneumonia_classifier.keras')
31
+ model = load_model(model_path)
32
+
33
+
34
+ class_names = ['NORMAL', 'PNEUMONIA']
35
+
36
+ # Display image and classify
37
+ if file is not None:
38
+ image = Image.open(file).convert('L')
39
+ st.image(image, caption="Uploaded X-ray", use_container_width=True)
40
+
41
+
42
+ img = np.array(image)
43
+ img = cv2.resize(img, (128, 128))
44
+ img = img / 255.0
45
+ img = np.expand_dims(img, axis=(0, -1))
46
+
47
+ # Predict
48
+ prediction = model.predict(img)
49
+ class_idx = np.argmax(prediction)
50
+ confidence = np.max(prediction)
51
+
52
+ # Display results
53
+ st.write("## Prediction: {}".format(class_names[class_idx]))
54
+ st.write("### Confidence: {:.2f}%".format(confidence * 100))
bgs/bg5.png ADDED

Git LFS Details

  • SHA256: 394100efd171a0f298a0e34bc5d8784c7156b14c1982744178fd3931ab739bc1
  • Pointer size: 133 Bytes
  • Size of remote file: 16.5 MB
bgs/bg5_blur.png ADDED

Git LFS Details

  • SHA256: 3e49901065c81cca82aa93e431220f4bd6d3934efa8e119dd9e696692346eeac
  • Pointer size: 132 Bytes
  • Size of remote file: 9.71 MB
model/pneumonia_classifier.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7853bb2d9df0bf44a6372c2a8af36575e7f07e4d8b73794d279a29531b2da6f
3
+ size 39699420
pyproject.toml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "pneumonia-classifier-app"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "numpy>=2.3.4",
9
+ "opencv-python>=4.11.0.86",
10
+ "pillow>=12.0.0",
11
+ "scipy>=1.16.3",
12
+ "streamlit>=1.51.0",
13
+ "tensorflow>=2.20.0",
14
+ ]