Thiyaga158 commited on
Commit
335b580
·
verified ·
1 Parent(s): 2eb6d08

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +119 -3
README.md CHANGED
@@ -1,6 +1,122 @@
1
  ---
2
- license: cc-by-nc-3.0
 
 
 
3
  tags:
4
- - custom
5
- - CNN
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ---
 
1
  ---
2
+ license: cc-by-nc-4.0
3
+ datasets:
4
+ - chest-xray-pneumonia
5
+ library_name: PyTorch
6
  tags:
7
+ - pneumonia-detection
8
+ - cnn
9
+ - medical-imaging
10
+ - binary-classification
11
+ - chest-xray
12
+ - healthcare
13
+ - pytorch
14
+ model-index:
15
+ - name: ImprovedPneumoniaCNN
16
+ results:
17
+ - task:
18
+ type: image-classification
19
+ name: Pneumonia Detection
20
+ metrics:
21
+ - name: Accuracy
22
+ type: accuracy
23
+ value: 0.9676
24
+ - name: F1 Score
25
+ type: f1
26
+ value: 0.9685
27
+ - name: AUC
28
+ type: auc
29
+ value: 0.9959
30
+ - name: Loss
31
+ type: loss
32
+ value: 0.0778
33
+ ---
34
+
35
+ # 🧠 ImprovedPneumoniaCNN: Pneumonia Detection from Chest X-rays
36
+
37
+ This repository hosts `ImprovedPneumoniaCNN`, a custom Convolutional Neural Network model designed to detect **Pneumonia** from chest X-ray images. It incorporates enhancements like dropout, batch normalization, SiLU activation, and Convolutional Block Attention Module (CBAM) for improved robustness and generalization.
38
+
39
+ ---
40
+
41
+ ## 📊 Evaluation Results
42
+
43
+ | Metric | Score |
44
+ |----------|---------|
45
+ | Accuracy | 96.76% |
46
+ | F1 Score | 0.9685 |
47
+ | AUC | 0.9959 |
48
+ | Loss | 0.0778 |
49
+
50
+ ---
51
+
52
+ ### Confusion Matrix
53
+
54
+ [[1680 42]
55
+ [ 74 1782]]
56
+
57
+ ---
58
+
59
+ ### Classification Report
60
+
61
+ | Class | Precision | Recall | F1-Score | Support |
62
+ |-----------|-----------|--------|----------|---------|
63
+ | Normal | 0.96 | 0.98 | 0.97 | 1722 |
64
+ | Pneumonia | 0.98 | 0.96 | 0.97 | 1856 |
65
+
66
+ ---
67
+
68
+ ## 🏗️ Architecture Highlights
69
+
70
+ - Custom CNN with residual blocks
71
+ - Uses **CBAM** attention for spatial and channel refinement
72
+ - **SiLU** activation for better non-linearity
73
+ - **Dropout** and **BatchNorm** for regularization
74
+ - Final **Global Average Pooling** + FC layer
75
+
76
+ ---
77
+
78
+ ## 🚀 How to Use
79
+
80
+ ### 🔧 Install Dependencies
81
+
82
+ ```bash
83
+ pip install torch torchvision albumentations scikit-learn matplotlib seaborn
84
+ import torch
85
+ from torchvision import transforms
86
+ from PIL import Image
87
+ from model import ImprovedPneumoniaCNN # make sure model is defined/imported
88
+
89
+ # Load model
90
+ model = ImprovedPneumoniaCNN()
91
+ model.load_state_dict(torch.load("improved_pneumonia_cnn.pth", map_location=torch.device('cpu')))
92
+ model.eval()
93
+
94
+ # Preprocess image
95
+ transform = transforms.Compose([
96
+ transforms.Grayscale(),
97
+ transforms.Resize((224, 224)),
98
+ transforms.ToTensor(),
99
+ ])
100
+
101
+ img = Image.open("path_to_chest_xray.jpg")
102
+ img_tensor = transform(img).unsqueeze(0)
103
+
104
+ # Predict
105
+ with torch.no_grad():
106
+ output = model(img_tensor)
107
+ prediction = torch.sigmoid(output).item()
108
+ print("Pneumonia" if prediction > 0.5 else "Normal")
109
+ ```
110
+ ---
111
+
112
+ ## Contributors
113
+ - [Thiyaga158](https://huggingface.co/Thiyaga158)
114
+
115
+ ---
116
+
117
+ ## License
118
+
119
+ This model is licensed under [CC BY-NC 3.0](https://creativecommons.org/licenses/by-nc/3.0/).
120
+ For research and educational use only.
121
+
122
  ---