saqialii commited on
Commit
2f24079
Β·
verified Β·
1 Parent(s): b7653f1

Add model card

Browse files
Files changed (1) hide show
  1. README.md +212 -0
README.md ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - pytorch
5
+ - computer-vision
6
+ - medical-imaging
7
+ - multi-task-learning
8
+ - classification
9
+ - regression
10
+ - single-cell
11
+ - microscopy
12
+ - white-blood-cell
13
+ datasets:
14
+ - BSCCM
15
+ - BCCD
16
+ language:
17
+ - en
18
+ pipeline_tag: image-classification
19
+ ---
20
+
21
+ # Single-Cell Phenotyping β€” Hybrid CNN-ViT Multi-Task Model
22
+
23
+ **Paper:** [Towards Label-Free Single-Cell Phenotyping Using Multi-Task Learning](https://arxiv.org/abs/2605.14717)
24
+ **Authors:** Saqib Nazir and Ardhendu Behera (Edge Hill University, UK)
25
+ **Conference:** ICPR 2026
26
+ **Code:** [github.com/saqibnaziir/Single-Cell-Phenotyping](https://github.com/saqibnaziir/Single-Cell-Phenotyping)
27
+
28
+ ---
29
+
30
+ ## Model Description
31
+
32
+ A unified deep learning framework that jointly performs **White Blood Cell (WBC) classification** and **continuous protein-expression regression** from label-free Differential Phase Contrast (DPC) microscopy images β€” *without fluorescent staining*.
33
+
34
+ ### Architecture
35
+
36
+ ```
37
+ Input: (B, 4, 28, 28) ← 4-channel DPC (Left, Right, Top, Bottom)
38
+ β”‚
39
+ └─ Shared ECA Channel Attention
40
+ β”œβ”€ CNN Branch: Stem β†’ InceptionΓ—2 + Residual β†’ (B, 196, 192)
41
+ └─ ViT Branch: Patch(4Γ—4) β†’ TransformerΓ—2 β†’ (B, 50, 128)
42
+ β”‚
43
+ └─ Cross-Modal Fusion (256-dim, learnable weights)
44
+ β”œβ”€ Task-Specific Refinement
45
+ └─ Task Gating (bidirectional cross-task exchange)
46
+ β”œβ”€ Classification Head β†’ (B, 3)
47
+ └─ Regression Head β†’ (B, 4)
48
+ ```
49
+
50
+ - **Parameters:** ~12M
51
+ - **FLOPs:** ~0.8 GFLOPs per 28Γ—28 image (real-time capable)
52
+ - **Input:** 4-channel DPC images, 28Γ—28 pixels
53
+
54
+ ### Tasks
55
+
56
+ | Task | Output | Classes / Markers |
57
+ |---|---|---|
58
+ | WBC Classification | 3 classes | Lymphocyte, Granulocyte, Monocyte |
59
+ | Protein Regression | 4 markers | CD45, CD3, CD19, CD14 |
60
+
61
+ ---
62
+
63
+ ## Files in This Repository
64
+
65
+ | File | Description |
66
+ |---|---|
67
+ | `bsccm_best_model.pth` | Best checkpoint on BSCCM dataset (91.3% accuracy) |
68
+ | `bccd_best_model.pth` | Best checkpoint on BCCD benchmark (93.77% accuracy) |
69
+
70
+ ---
71
+
72
+ ## Performance
73
+
74
+ ### BSCCM Dataset
75
+
76
+ | Metric | Value |
77
+ |---|---|
78
+ | WBC Classification Accuracy | **91.3%** |
79
+ | Macro F1-Score | **0.92** |
80
+ | Pearson r (CD16 regression) | **0.73** |
81
+ | RMSE | 0.68 |
82
+
83
+ ### BCCD Benchmark (Classification Only)
84
+
85
+ | Class | Precision | Recall | F1 |
86
+ |---|---|---|---|
87
+ | Lymphocyte | 1.000 | 1.000 | 1.000 |
88
+ | Granulocyte | 0.889 | 1.000 | 0.941 |
89
+ | Monocyte | 1.000 | 0.750 | 0.857 |
90
+ | **Macro Avg.** | **0.963** | **0.917** | **0.933** |
91
+
92
+ Overall BCCD accuracy: **93.77%**
93
+
94
+ ---
95
+
96
+ ## Usage
97
+
98
+ ### Installation
99
+
100
+ ```bash
101
+ git clone https://github.com/saqibnaziir/Single-Cell-Phenotyping.git
102
+ cd Single-Cell-Phenotyping
103
+ pip install -r requirements.txt
104
+ ```
105
+
106
+ ### Load Model
107
+
108
+ ```python
109
+ import torch
110
+ from huggingface_hub import hf_hub_download
111
+ from model import create_model
112
+
113
+ # Download checkpoint
114
+ ckpt_path = hf_hub_download(
115
+ repo_id="saqialii/single-cell-phenotyping",
116
+ filename="bsccm_best_model.pth"
117
+ )
118
+
119
+ # Create model and load weights
120
+ model = create_model(num_classes=3, num_proteins=4, img_size=28, in_channels=4)
121
+ checkpoint = torch.load(ckpt_path, map_location='cpu', weights_only=False)
122
+ model.load_state_dict(checkpoint['model_state_dict'])
123
+ model.eval()
124
+
125
+ print(f"Loaded model β€” best val accuracy: {checkpoint['best_val_acc']:.2f}%")
126
+ ```
127
+
128
+ ### Inference
129
+
130
+ ```python
131
+ import torch
132
+ import torch.nn.functional as F
133
+
134
+ # Input: (B, 4, 28, 28) β€” 4-channel DPC image, normalised to [-1, 1]
135
+ image = torch.randn(1, 4, 28, 28) # replace with real image
136
+
137
+ with torch.no_grad():
138
+ cls_logits, prot_preds = model(image)
139
+
140
+ # Cell type classification
141
+ probs = F.softmax(cls_logits, dim=1)
142
+ class_names = ['Lymphocyte', 'Granulocyte', 'Monocyte']
143
+ predicted_class = class_names[probs.argmax().item()]
144
+ confidence = probs.max().item()
145
+
146
+ print(f"Predicted: {predicted_class} ({confidence:.1%})")
147
+
148
+ # Protein expression (Z-scored)
149
+ protein_names = ['CD45', 'CD3', 'CD19', 'CD14']
150
+ for name, val in zip(protein_names, prot_preds[0].tolist()):
151
+ print(f" {name}: {val:.3f}")
152
+ ```
153
+
154
+ ### Data Preparation
155
+
156
+ ```bash
157
+ # Download BSCCM dataset
158
+ pip install bsccm
159
+ python -c "from bsccm import download_dataset; download_dataset('./data', mnist=True)"
160
+
161
+ # Train from scratch
162
+ python train.py --data_path ./data/BSCCMNIST --save_dir checkpoints/run1
163
+
164
+ # Evaluate
165
+ python evaluate.py \
166
+ --model_path checkpoints/run1/best_model.pth \
167
+ --data_path ./data/BSCCMNIST \
168
+ --output_dir evaluation_results
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Dataset
174
+
175
+ **BSCCM** (Berkeley Single Cell Computational Microscopy):
176
+ - 7,889 single-cell DPC images at 28Γ—28 pixels
177
+ - 3 WBC classes: Lymphocyte (456), Granulocyte (736), Monocyte (226) β€” test split
178
+ - 4 protein markers measured by fluorescence: CD45, CD3, CD19, CD14
179
+ - Source: [Waller-Lab/BSCCM](https://github.com/Waller-Lab/BSCCM)
180
+
181
+ **BCCD** (Blood Cell Images):
182
+ - ~12,000 RGB images at 128Γ—128 pixels (4-class β†’ mapped to 3-class)
183
+ - Source: [Kaggle: Blood Cell Images](https://www.kaggle.com/datasets/paultimothymooney/blood-cells)
184
+
185
+ ---
186
+
187
+ ## Citation
188
+
189
+ ```bibtex
190
+ @inproceedings{nazir2026label,
191
+ title = {Towards Label-Free Single-Cell Phenotyping Using Multi-Task Learning},
192
+ author = {Nazir, Saqib and Behera, Ardhendu},
193
+ booktitle = {Proceedings of the International Conference on Pattern Recognition (ICPR)},
194
+ year = {2026},
195
+ note = {arXiv:2605.14717}
196
+ }
197
+ ```
198
+
199
+ ```bibtex
200
+ @article{pinkard2024berkeley,
201
+ title = {Berkeley Single Cell Computational Microscopy Dataset},
202
+ author = {Pinkard, Henry and others},
203
+ journal = {arXiv preprint arXiv:2402.06191},
204
+ year = {2024}
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ [MIT License](https://github.com/saqibnaziir/Single-Cell-Phenotyping/blob/main/LICENSE) β€” Saqib Nazir, Ardhendu Behera, Edge Hill University, 2026