Swin-Tiny Correctly Classified 92.4% of Lung CT Slices, EfficientNet-B0 Got 83.2%
A developer compared neural networks on chest CT scans. In the first task, the model has to look at a slice and identify the type of pathology, or call it normal. On 630 test images, Swin-Tiny classified 92.4% correctly and EfficientNet-B0 got 83.2%, but Swin took twice as long to train. No network managed to segment small nodules: there were only 113 training nodules. The takeaway: with small datasets, check the input and the sample first, and only then compare models.
AI-processed from Habr AI; edited by Hamidun News
Imagine you are choosing a neural network to assist a radiologist who reviews hundreds of chest CT slices and risks missing a small nodule. The numbers in published papers are hard to compare: each author uses their own data and their own preprocessing. So the developer ran four popular architectures under identical conditions.
In the classification task, where the model must name the pathology type from a CT slice (adenocarcinoma, large cell carcinoma or squamous cell carcinoma) or call it normal, the Swin-Tiny transformer reached 92.4% accuracy against 83.2% for the convolutional EfficientNet-B0 on a test set of 630 images.
In the segmentation task, which means labeling the pixels that belong to a nodule, a fair comparison did not work out. But the effort produced a useful breakdown of how a project can fail before training even begins.
What was compared, and on what data
There were two tasks. The first was nodule segmentation: the network marks which points of a 3D scan belong to a lesion. Here the developer compared UNet 3+ (a network with connections between all levels; she wrote the 3D variant herself) and nnU-Net v2, a ready-made system that picks its own preprocessing and training parameters. The data came from the open LIDC-IDRI dataset, but because of the limits of free Kaggle, she assembled a subsample of 148 patients, 48 of whom had nodules. The split was done by patient (103, 22 and 23 people), so that slices from one person would not end up in both training and test sets.
The second task was slice classification. For it she used the Chest CT-Scan Images dataset from Kaggle: 1226 images for training, 148 for validation and 630 for testing. She compared EfficientNet-B0 (4M parameters) and Swin-Tiny (27.5M parameters, a transformer with shifted attention windows). Both were pretrained on ImageNet and trained identically: 20 epochs, Adam, learning rate 1e-4.
Classification: Swin is more accurate, EfficientNet is cheaper
Beyond accuracy, Swin-Tiny also won on macro-F1, which averages quality across all four classes: 93.6% against 84.1%. The price is time and size: 85.6 minutes of training instead of 44.4, and almost seven times as many parameters.
The picture varies by class. Swin finds large cell carcinoma in 100% of cases, EfficientNet in 73%. But both models confused adenocarcinoma with squamous cell carcinoma: in 17% of cases for EfficientNet and 15% for Swin. In other words, the transformer did not resolve the main confusion; it simply did better on everything else.
The caveats are significant: each model was run once, there are no confidence intervals, and the sets were not checked for duplicates across splits. The explanation involving hierarchical features and shifted windows remains a hypothesis, since no ablations were run.
Segmentation: why nothing generalized
In the final experiment on crops around nodules, a standard 3D UNet and 3D UNet 3+ reached a test Dice score (a measure of overlap with physicians' annotations, where 100% is a perfect match) of only 1.3% and 1.7%. The difference between the networks is not statistically significant (Wilcoxon test, p = 0.53). The network memorized the training nodules: the metric rose on training data and fell almost to zero on validation. The nodules are small, with a median diameter of about 6 voxels, and there were only 113 training examples from 33 patients, with 27 nodules in the test set.
The author herself does not consider the earlier figures reliable: nnU-Net reached a validation Dice of 48% and UNet 3+ reached 32%, but the samples changed between runs, and nnU-Net trained for 30 epochs instead of the standard 1000.
The most valuable part is the list of errors found during debugging:
- Double normalization. The files were already stored in the 0 to 1 range, and a Hounsfield-unit window was applied on top. The image became almost constant, and the network had nothing to learn from.
- Too few examples with a nodule. With random cropping, only 8–10% of patches contained a nodule. Centering crops on the nodule with a random shift raised that share to half.
- Dice-loss behavior on empty patches. With ε = 1, the loss looks "good" on nodule-free frames and pulls predictions toward zero. With ε = 1e-5, the behavior normalized.
- The two-patch test. If a network cannot overfit two examples, the problem lies in the pipeline. AdamW with lr 1e-3 gave a Dice of 0%, while SGD with momentum 0.99 and lr 1e-2 reached 85.2% in 200 steps.
What to take away from this
If you are choosing between a lightweight convolutional network and a transformer for image classification, on this dataset Swin delivers roughly 9 percentage points more accuracy but trains twice as long. EfficientNet may be enough for a prototype, while for a final model it is worth testing Swin on your own data and across several runs.
For segmentation, the lesson is different: before comparing architectures, check the range of input values, the share of positive examples in a batch, and the loss behavior on empty data. A run on two or three examples takes minutes and shows whether the model or the pipeline is at fault. The author plans to repeat the segmentation on a larger dataset. For now, this is an error analysis from a small experiment, not a ready-made benchmark for clinical use.
- Nov 6, 2026QVikhr-3-4B on a 1.5K ₽ GPU-less VPS correctly tagged 20 of 20 requests
- Feb 17, 2026Cohere releases Tiny Aya, a family of open multilingual models
- Jul 17, 2026Photonic AI chip computes at the speed of light: 99% accuracy without overheating
- Nov 22, 2026Russian Voice AI Squeezed Into 21 MB: tiny-voca-ru Runs Offline on a CPU
Key Questions Answered
What was compared, and on what data?
There were two tasks. The first was nodule segmentation: the network marks which points of a 3D scan belong to a lesion. Here the developer compared UNet 3+ (a network with connections between all levels; she wrote the 3D variant herself) and nnU-Net v2, a ready-made system that picks its own preprocessing and training parameters. The data came from the open LIDC-IDRI dataset, but because of the limits of free Kaggle, she assembled a subsample of 148 patients, 48 of whom had nodules.
What are the key details on Classification: Swin is more accurate, EfficientNet is cheaper?
Beyond accuracy, Swin-Tiny also won on macro-F1, which averages quality across all four classes: 93.6% against 84.1%. The price is time and size: 85.6 minutes of training instead of 44.4, and almost seven times as many parameters. The picture varies by class. Swin finds large cell carcinoma in 100% of cases, EfficientNet in 73%. But both models confused adenocarcinoma with squamous cell carcinoma: in 17% of cases for EfficientNet and 15% for Swin.
What are the key details on Segmentation: why nothing generalized?
In the final experiment on crops around nodules, a standard 3D UNet and 3D UNet 3+ reached a test Dice score (a measure of overlap with physicians' annotations, where 100% is a perfect match) of only 1.3% and 1.7%. The difference between the networks is not statistically significant (Wilcoxon test, p = 0.53). The network memorized the training nodules: the metric rose on training data and fell almost to zero on validation.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
