Johnyquest7 commited on
Commit
28a3a0c
·
verified ·
1 Parent(s): f063471

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +339 -109
README.md CHANGED
@@ -3,13 +3,21 @@ library_name: transformers
3
  license: apache-2.0
4
  base_model: microsoft/swinv2-base-patch4-window8-256
5
  tags:
 
 
 
 
 
6
  - generated_from_trainer
7
  - ml-intern
8
  datasets:
9
- - generator
10
  metrics:
11
  - accuracy
12
  - f1
 
 
 
13
  model-index:
14
  - name: TN5000_model
15
  results:
@@ -17,124 +25,346 @@ model-index:
17
  name: Image Classification
18
  type: image-classification
19
  dataset:
20
- name: generator
21
- type: generator
22
- config: default
23
- split: train
24
- args: default
25
  metrics:
26
  - name: Accuracy
27
  type: accuracy
28
  value: 0.872
29
  - name: F1
30
  type: f1
31
- value: 0.9080459770114943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ---
33
 
34
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
35
- should probably proofread and complete it, then remove this comment. -->
36
-
37
- # TN5000_model
38
-
39
- This model is a fine-tuned version of [microsoft/swinv2-base-patch4-window8-256](https://huggingface.co/microsoft/swinv2-base-patch4-window8-256) on the generator dataset.
40
- It achieves the following results on the evaluation set:
41
- - Loss: 0.1293
42
- - Accuracy: 0.872
43
- - F1: 0.9080
44
- - Sensitivity: 0.8745
45
- - Specificity: 0.8654
46
- - Ppv: 0.9442
47
- - Npv: 0.7258
48
- - Auc Roc: 0.9367
49
- - Tp: 474
50
- - Tn: 180
51
- - Fp: 28
52
- - Fn: 68
53
-
54
- ## Model description
55
-
56
- More information needed
57
-
58
- ## Intended uses & limitations
59
-
60
- More information needed
61
-
62
- ## Training and evaluation data
63
-
64
- More information needed
65
-
66
- ## Training procedure
67
-
68
- ### Training hyperparameters
69
-
70
- The following hyperparameters were used during training:
71
- - learning_rate: 2e-05
72
- - train_batch_size: 16
73
- - eval_batch_size: 16
74
- - seed: 42
75
- - gradient_accumulation_steps: 2
76
- - total_train_batch_size: 32
77
- - optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
78
- - lr_scheduler_type: linear
79
- - lr_scheduler_warmup_steps: 0.1
80
- - num_epochs: 30
81
-
82
- ### Training results
83
-
84
- | Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 | Sensitivity | Specificity | Ppv | Npv | Auc Roc | Tp | Tn | Fp | Fn |
85
- |:-------------:|:-----:|:----:|:---------------:|:--------:|:------:|:-----------:|:-----------:|:------:|:------:|:-------:|:---:|:---:|:--:|:---:|
86
- | 0.3555 | 1.0 | 88 | 0.2034 | 0.6786 | 0.7604 | 0.714 | 0.59 | 0.8132 | 0.4521 | 0.7130 | 357 | 118 | 82 | 143 |
87
- | 0.2755 | 2.0 | 176 | 0.1604 | 0.7314 | 0.7920 | 0.716 | 0.77 | 0.8861 | 0.5203 | 0.8209 | 358 | 154 | 46 | 142 |
88
- | 0.2580 | 3.0 | 264 | 0.1648 | 0.8143 | 0.8684 | 0.858 | 0.705 | 0.8791 | 0.6651 | 0.8609 | 429 | 141 | 59 | 71 |
89
- | 0.2399 | 4.0 | 352 | 0.1343 | 0.7686 | 0.8208 | 0.742 | 0.835 | 0.9183 | 0.5642 | 0.8774 | 371 | 167 | 33 | 129 |
90
- | 0.2292 | 5.0 | 440 | 0.1547 | 0.8757 | 0.9153 | 0.94 | 0.715 | 0.8918 | 0.8266 | 0.9116 | 470 | 143 | 57 | 30 |
91
- | 0.2285 | 6.0 | 528 | 0.1153 | 0.8186 | 0.8656 | 0.818 | 0.82 | 0.9191 | 0.6431 | 0.9161 | 409 | 164 | 36 | 91 |
92
- | 0.2417 | 7.0 | 616 | 0.1111 | 0.8171 | 0.8621 | 0.8 | 0.86 | 0.9346 | 0.6324 | 0.9171 | 400 | 172 | 28 | 100 |
93
- | 0.1748 | 8.0 | 704 | 0.1145 | 0.8514 | 0.8919 | 0.858 | 0.835 | 0.9286 | 0.7017 | 0.9271 | 429 | 167 | 33 | 71 |
94
- | 0.1901 | 9.0 | 792 | 0.1489 | 0.8857 | 0.9206 | 0.928 | 0.78 | 0.9134 | 0.8125 | 0.9208 | 464 | 156 | 44 | 36 |
95
- | 0.1872 | 10.0 | 880 | 0.1162 | 0.8514 | 0.8919 | 0.858 | 0.835 | 0.9286 | 0.7017 | 0.9218 | 429 | 167 | 33 | 71 |
96
- | 0.1439 | 11.0 | 968 | 0.1108 | 0.8014 | 0.8478 | 0.774 | 0.87 | 0.9370 | 0.6063 | 0.9259 | 387 | 174 | 26 | 113 |
97
- | 0.1868 | 12.0 | 1056 | 0.1185 | 0.8714 | 0.9076 | 0.884 | 0.84 | 0.9325 | 0.7434 | 0.9320 | 442 | 168 | 32 | 58 |
98
- | 0.2002 | 13.0 | 1144 | 0.1376 | 0.8857 | 0.9205 | 0.926 | 0.785 | 0.9150 | 0.8093 | 0.9317 | 463 | 157 | 43 | 37 |
99
- | 0.2023 | 14.0 | 1232 | 0.1339 | 0.8857 | 0.9195 | 0.914 | 0.815 | 0.9251 | 0.7913 | 0.9350 | 457 | 163 | 37 | 43 |
100
- | 0.1582 | 15.0 | 1320 | 0.1346 | 0.8929 | 0.9252 | 0.928 | 0.805 | 0.9225 | 0.8173 | 0.9338 | 464 | 161 | 39 | 36 |
101
- | 0.1488 | 16.0 | 1408 | 0.1319 | 0.8957 | 0.9266 | 0.922 | 0.83 | 0.9313 | 0.8098 | 0.9366 | 461 | 166 | 34 | 39 |
102
- | 0.1249 | 17.0 | 1496 | 0.1280 | 0.87 | 0.9061 | 0.878 | 0.85 | 0.9360 | 0.7359 | 0.9370 | 439 | 170 | 30 | 61 |
103
- | 0.1553 | 18.0 | 1584 | 0.1121 | 0.8571 | 0.8943 | 0.846 | 0.885 | 0.9484 | 0.6969 | 0.9390 | 423 | 177 | 23 | 77 |
104
- | 0.1083 | 19.0 | 1672 | 0.1675 | 0.9029 | 0.9331 | 0.948 | 0.79 | 0.9186 | 0.8587 | 0.9381 | 474 | 158 | 42 | 26 |
105
- | 0.1379 | 20.0 | 1760 | 0.1535 | 0.9 | 0.9308 | 0.942 | 0.795 | 0.9199 | 0.8457 | 0.9340 | 471 | 159 | 41 | 29 |
106
- | 0.1458 | 21.0 | 1848 | 0.1915 | 0.9043 | 0.9344 | 0.954 | 0.78 | 0.9155 | 0.8715 | 0.9345 | 477 | 156 | 44 | 23 |
107
- | 0.1322 | 22.0 | 1936 | 0.1244 | 0.8786 | 0.9126 | 0.888 | 0.855 | 0.9387 | 0.7533 | 0.9399 | 444 | 171 | 29 | 56 |
108
- | 0.1438 | 23.0 | 2024 | 0.1519 | 0.8757 | 0.9122 | 0.904 | 0.805 | 0.9206 | 0.7703 | 0.9356 | 452 | 161 | 39 | 48 |
109
- | 0.1265 | 24.0 | 2112 | 0.1421 | 0.8871 | 0.9204 | 0.914 | 0.82 | 0.9270 | 0.7923 | 0.9378 | 457 | 164 | 36 | 43 |
110
- | 0.1118 | 25.0 | 2200 | 0.2165 | 0.9057 | 0.9358 | 0.962 | 0.765 | 0.9110 | 0.8895 | 0.9380 | 481 | 153 | 47 | 19 |
111
- | 0.0971 | 26.0 | 2288 | 0.1557 | 0.8857 | 0.9194 | 0.912 | 0.82 | 0.9268 | 0.7885 | 0.9342 | 456 | 164 | 36 | 44 |
112
- | 0.1235 | 27.0 | 2376 | 0.1394 | 0.88 | 0.9143 | 0.896 | 0.84 | 0.9333 | 0.7636 | 0.9376 | 448 | 168 | 32 | 52 |
113
-
114
-
115
- ### Framework versions
116
-
117
- - Transformers 5.8.0
118
- - Pytorch 2.11.0+cu130
119
- - Datasets 4.8.5
120
- - Tokenizers 0.22.2
121
-
122
- <!-- ml-intern-provenance -->
123
- ## Generated by ML Intern
124
-
125
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
126
-
127
- - Try ML Intern: https://smolagents-ml-intern.hf.space
128
- - Source code: https://github.com/huggingface/ml-intern
129
-
130
- ## Usage
131
 
132
  ```python
133
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- model_id = 'Johnyquest7/TN5000_model'
136
- tokenizer = AutoTokenizer.from_pretrained(model_id)
137
- model = AutoModelForCausalLM.from_pretrained(model_id)
 
 
 
 
 
 
 
 
 
 
 
 
138
  ```
139
 
140
- For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  license: apache-2.0
4
  base_model: microsoft/swinv2-base-patch4-window8-256
5
  tags:
6
+ - image-classification
7
+ - medical-imaging
8
+ - thyroid
9
+ - ultrasound
10
+ - swinv2
11
  - generated_from_trainer
12
  - ml-intern
13
  datasets:
14
+ - sadib2026/roi-dataset-tn5000
15
  metrics:
16
  - accuracy
17
  - f1
18
+ - auc_roc
19
+ - sensitivity
20
+ - specificity
21
  model-index:
22
  - name: TN5000_model
23
  results:
 
25
  name: Image Classification
26
  type: image-classification
27
  dataset:
28
+ name: TN5000 ROI Dataset
29
+ type: image-classification
 
 
 
30
  metrics:
31
  - name: Accuracy
32
  type: accuracy
33
  value: 0.872
34
  - name: F1
35
  type: f1
36
+ value: 0.908
37
+ - name: AUC-ROC
38
+ type: auc_roc
39
+ value: 0.937
40
+ - name: Sensitivity
41
+ type: sensitivity
42
+ value: 0.875
43
+ - name: Specificity
44
+ type: specificity
45
+ value: 0.865
46
+ ---
47
+
48
+ # TN5000 Thyroid Ultrasound Classifier
49
+
50
+ **Fine-tuned SwinV2-Base for Benign vs Malignant Thyroid Nodule Classification**
51
+
52
+ [![Model](https://img.shields.io/badge/Model-HuggingFace-yellow)](https://huggingface.co/Johnyquest7/TN5000_model)
53
+ [![Demo](https://img.shields.io/badge/Demo-Gradio-green)](https://huggingface.co/spaces/Johnyquest7/tn5000-thyroid-demo)
54
+ [![Dataset](https://img.shields.io/badge/Dataset-Kaggle-blue)](https://www.kaggle.com/datasets/sadib2026/roi-dataset-tn5000)
55
+
56
+ ---
57
+
58
+ ## 📋 Table of Contents
59
+
60
+ 1. [Overview](#overview)
61
+ 2. [Model Architecture](#model-architecture)
62
+ 3. [Dataset](#dataset)
63
+ 4. [Training Methodology](#training-methodology)
64
+ 5. [Results](#results)
65
+ 6. [External Validation](#external-validation)
66
+ 7. [How to Use](#how-to-use)
67
+ 8. [Limitations & Disclaimers](#limitations--disclaimers)
68
+ 9. [Citation](#citation)
69
+
70
+ ---
71
+
72
+ ## Overview
73
+
74
+ This model classifies thyroid ultrasound images as **benign** or **malignant**, designed to assist in the early detection of thyroid cancer. It was fine-tuned from Microsoft's SwinV2-Base vision transformer on the TN5000 ROI dataset from Kaggle.
75
+
76
+ **Key Design Decisions:**
77
+ - **Optimized for sensitivity** (87.5%) to minimize missed malignancies — critical in cancer screening
78
+ - **AUC-ROC of 0.94** indicates excellent discriminative ability
79
+ - **Focal loss with class weighting** handles the benign/malignant class imbalance
80
+ - **Early stopping** prevents overfitting on the small medical dataset
81
+
82
+ ---
83
+
84
+ ## Model Architecture
85
+
86
+ | Property | Value |
87
+ |----------|-------|
88
+ | **Base Model** | [microsoft/swinv2-base-patch4-window8-256](https://huggingface.co/microsoft/swinv2-base-patch4-window8-256) |
89
+ | **Architecture** | Swin Transformer V2 |
90
+ | **Parameters** | 86.9M |
91
+ | **Input Size** | 256 × 256 |
92
+ | **Patch Size** | 4 × 4 |
93
+ | **Window Size** | 8 × 8 |
94
+ | **Number of Classes** | 2 (benign, malignant) |
95
+ | **License** | Apache 2.0 |
96
+
97
+ **Why SwinV2?**
98
+ Swin Transformers use hierarchical feature maps and shifted window attention, making them particularly effective for medical imaging where local texture patterns (echogenicity, microcalcifications, irregular margins) are diagnostically important. SwinV2 improves training stability with a cosine attention mechanism and larger model capacity.
99
+
100
+ ---
101
+
102
+ ## Dataset
103
+
104
+ ### Primary Training Dataset: TN5000 ROI
105
+
106
+ - **Source:** [Kaggle - ROI Dataset TN5000](https://www.kaggle.com/datasets/sadib2026/roi-dataset-tn5000)
107
+ - **Type:** Thyroid ultrasound Region-of-Interest (ROI) patches
108
+ - **Total Images:** 4,250
109
+
110
+ | Split | Images | Benign | Malignant |
111
+ |-------|--------|--------|-----------|
112
+ | Train (80%) | 2,800 | ~1,600 | ~1,200 |
113
+ | Validation (20%) | 700 | ~400 | ~300 |
114
+ | Test (held-out) | 750 | ~400 | ~350 |
115
+
116
+ **Class Distribution:** The dataset is moderately imbalanced with more benign cases. We used **balanced class weights** (benign: 1.75, malignant: 0.70) and **focal loss** (γ=2.0) to prioritize malignant case detection.
117
+
118
+ ### External Validation Dataset
119
+
120
+ - **Source:** [Johnyquest7/thyroid-cancer-classification-ultrasound-dataset](https://huggingface.co/datasets/Johnyquest7/thyroid-cancer-classification-ultrasound-dataset)
121
+ - **Images:** 3,115 total (train + test splits)
122
+ - **Purpose:** Independent validation on unseen data from a different source
123
+
124
+ ---
125
+
126
+ ## Training Methodology
127
+
128
+ ### Data Preprocessing
129
+
130
+ | Transform | Training | Validation/Test |
131
+ |-----------|----------|-----------------|
132
+ | Resize | RandomResizedCrop(256) | Resize(256) + CenterCrop(256) |
133
+ | Horizontal Flip | 50% probability | No |
134
+ | Rotation | ±10° | No |
135
+ | Color Jitter | brightness=0.2, contrast=0.2 | No |
136
+ | Normalization | ImageNet mean/std | ImageNet mean/std |
137
+
138
+ ### Training Configuration
139
+
140
+ ```python
141
+ learning_rate: 2e-5
142
+ batch_size: 16 (per device)
143
+ gradient_accumulation_steps: 2
144
+ effective_batch_size: 32
145
+ epochs: 30 (early stopping patience: 5)
146
+ warmup_ratio: 0.1
147
+ optimizer: AdamW (β1=0.9, β2=0.999)
148
+ scheduler: Linear with warmup
149
+ mixed_precision: bf16
150
+ seed: 42
151
+ ```
152
+
153
+ ### Loss Function: Focal Loss
154
+
155
+ Standard cross-entropy treats all misclassifications equally. In thyroid screening, **missing a malignant case (false negative) is far more costly** than a false alarm. We used focal loss:
156
+
157
+ ```
158
+ FL(pt) = −(1 − pt)^γ · log(pt)
159
+ ```
160
+
161
+ With γ=2.0, the model focuses learning on hard-to-classify malignant cases. Class weights further upweight the minority malignant class.
162
+
163
+ ### Model Selection Criterion
164
+
165
+ The best model was selected by **validation AUC-ROC** (not accuracy), ensuring optimal discrimination between benign and malignant cases across all thresholds.
166
+
167
+ ---
168
+
169
+ ## Results
170
+
171
+ ### Validation Set (700 images)
172
+
173
+ | Metric | Value |
174
+ |--------|-------|
175
+ | **Accuracy** | 87.9% |
176
+ | **F1-Score** | 91.3% |
177
+ | **Sensitivity (Recall)** | 88.8% |
178
+ | **Specificity** | 85.5% |
179
+ | **PPV (Precision)** | 93.9% |
180
+ | **NPV** | 75.3% |
181
+ | **AUC-ROC** | **0.940** |
182
+
183
+ **Confusion Matrix:**
184
+ ```
185
+ Predicted
186
+ Benign Malignant
187
+ Actual Benign 171 29
188
+ Malignant 56 444
189
+ ```
190
+
191
+ ### Test Set (750 images — held out)
192
+
193
+ | Metric | Value |
194
+ |--------|-------|
195
+ | **Accuracy** | 87.2% |
196
+ | **F1-Score** | 90.8% |
197
+ | **Sensitivity (Recall)** | 87.5% |
198
+ | **Specificity** | 86.5% |
199
+ | **PPV (Precision)** | 94.4% |
200
+ | **NPV** | 72.6% |
201
+ | **AUC-ROC** | **0.937** |
202
+
203
+ **Confusion Matrix:**
204
+ ```
205
+ Predicted
206
+ Benign Malignant
207
+ Actual Benign 180 28
208
+ Malignant 68 474
209
+ ```
210
+
211
+ ### Training Curves
212
+
213
+ The model converged around epoch 18-22 with validation AUC-ROC peaking at 0.940. Early stopping triggered at epoch 27, loading the best checkpoint.
214
+
215
+ | Epoch | Train Loss | Val AUC-ROC | Val Sensitivity | Val Specificity |
216
+ |-------|-----------|-------------|-----------------|-----------------|
217
+ | 1 | 0.356 | 0.713 | 0.714 | 0.590 |
218
+ | 5 | 0.229 | 0.912 | 0.940 | 0.715 |
219
+ | 10 | 0.187 | 0.922 | 0.858 | 0.835 |
220
+ | 15 | 0.148 | 0.934 | 0.928 | 0.805 |
221
+ | 18 | 0.125 | **0.939** | 0.846 | 0.885 |
222
+ | 22 | 0.143 | **0.940** | 0.888 | 0.855 |
223
+
224
  ---
225
 
226
+ ## External Validation
227
+
228
+ To assess generalization, we tested the model on an independent dataset without any fine-tuning:
229
+
230
+ | Metric | Value |
231
+ |--------|-------|
232
+ | **Accuracy** | 66.8% |
233
+ | **F1-Score** | 44.7% |
234
+ | **Sensitivity** | 34.5% |
235
+ | **Specificity** | 87.4% |
236
+ | **PPV** | 63.5% |
237
+ | **NPV** | 67.7% |
238
+ | **AUC-ROC** | **0.707** |
239
+
240
+ **Confusion Matrix (External):**
241
+ ```
242
+ Predicted
243
+ Benign Malignant
244
+ Actual Benign 1665 240
245
+ Malignant 793 417
246
+ ```
247
+
248
+ **Analysis:** The external validation shows a significant performance drop (AUC 0.94 → 0.71), which is expected due to:
249
+ 1. **Domain shift:** Different ultrasound machines, protocols, and image preprocessing
250
+ 2. **Different ROI extraction:** The external dataset may use different cropping strategies
251
+ 3. **Population differences:** Different patient demographics and disease prevalence
252
+
253
+ This highlights the importance of **domain adaptation** or **fine-tuning on local data** before clinical deployment.
254
+
255
+ ---
256
+
257
+ ## How to Use
258
+
259
+ ### Quick Inference with Pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  ```python
262
+ from transformers import pipeline
263
+ from PIL import Image
264
+
265
+ # Load model
266
+ classifier = pipeline("image-classification", model="Johnyquest7/TN5000_model")
267
+
268
+ # Predict
269
+ image = Image.open("thyroid_ultrasound.png").convert("RGB")
270
+ results = classifier(image)
271
+
272
+ # Results format:
273
+ # [{'label': 'malignant', 'score': 0.944}, {'label': 'benign', 'score': 0.056}]
274
+ ```
275
+
276
+ ### Manual Inference
277
+
278
+ ```python
279
+ import torch
280
+ from PIL import Image
281
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
282
+
283
+ # Load model and processor
284
+ model = AutoModelForImageClassification.from_pretrained("Johnyquest7/TN5000_model")
285
+ processor = AutoImageProcessor.from_pretrained("Johnyquest7/TN5000_model")
286
 
287
+ # Preprocess
288
+ image = Image.open("thyroid_ultrasound.png").convert("RGB")
289
+ inputs = processor(image, return_tensors="pt")
290
+
291
+ # Predict
292
+ with torch.no_grad():
293
+ logits = model(**inputs).logits
294
+ probs = torch.softmax(logits, dim=-1)[0]
295
+
296
+ # Get probabilities
297
+ malignant_prob = probs[1].item()
298
+ benign_prob = probs[0].item()
299
+
300
+ print(f"Malignant: {malignant_prob:.1%}")
301
+ print(f"Benign: {benign_prob:.1%}")
302
  ```
303
 
304
+ ### Gradio Demo
305
+
306
+ Try the live demo: [🩺 Thyroid Nodule Classifier Demo](https://huggingface.co/spaces/Johnyquest7/tn5000-thyroid-demo)
307
+
308
+ ---
309
+
310
+ ## Limitations & Disclaimers
311
+
312
+ ⚠️ **CRITICAL: This model is for research and educational purposes only.**
313
+
314
+ 1. **Not FDA-approved** for clinical use
315
+ 2. **External validation showed performance degradation** (AUC 0.71 vs 0.94) — domain shift is a real concern
316
+ 3. **Trained on ROI patches**, not full ultrasound images — the model expects pre-cropped nodule regions
317
+ 4. **Class imbalance** in training data may bias predictions
318
+ 5. **No multi-institutional validation** — performance may vary across hospitals and equipment
319
+ 6. **Always consult a radiologist or endocrinologist** for diagnosis
320
+
321
+ **Intended Use Cases:**
322
+ - Research on AI-assisted thyroid screening
323
+ - Educational tool for medical students
324
+ - Prototype for integration into PACS systems (with proper validation)
325
+
326
+ **Not Intended For:**
327
+ - Direct patient diagnosis
328
+ - Replacing human radiologists
329
+ - Screening without supervision
330
+
331
+ ---
332
+
333
+ ## Citation
334
+
335
+ If you use this model in your research, please cite:
336
+
337
+ ```bibtex
338
+ @misc{tn5000_model,
339
+ title={TN5000 Thyroid Ultrasound Classifier},
340
+ author={Johnyquest7},
341
+ year={2026},
342
+ howpublished={\url{https://huggingface.co/Johnyquest7/TN5000_model}},
343
+ note={Fine-tuned SwinV2-Base for benign vs malignant thyroid nodule classification}
344
+ }
345
+ ```
346
+
347
+ **Base Model:**
348
+ ```bibtex
349
+ @article{liu2022swinv2,
350
+ title={Swin Transformer V2: Scaling Up Capacity and Resolution},
351
+ author={Liu, Ze and Hu, Han and Lin, Yutong and Yao, Zhuliang and Xie, Zhenda and Wei, Yixuan and Ning, Jia and Cao, Yue and Zhang, Zheng and Dong, Li and Wei, Furu and Guo, Baining},
352
+ journal={International Conference on Computer Vision (ICCV)},
353
+ year={2021}
354
+ }
355
+ ```
356
+
357
+ **Dataset:**
358
+ - TN5000 ROI Dataset: [Kaggle](https://www.kaggle.com/datasets/sadib2026/roi-dataset-tn5000)
359
+
360
+ ---
361
+
362
+ ## Acknowledgments
363
+
364
+ - Model trained using Hugging Face Transformers and Datasets libraries
365
+ - Compute provided by Hugging Face GPU credits
366
+ - Base model: Microsoft SwinV2-Base
367
+
368
+ ---
369
+
370
+ *Generated by ML Intern — an agent for machine learning research and development on the Hugging Face Hub.*