---
id: 16494
lang: en
title: "Swin-Tiny Correctly Classified 92.4% of Lung CT Slices, EfficientNet-B0 Got 83.2%"
published_at: "2026-11-20 12:27:26"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1110294/?utm_campaign=1110294&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/16494"
categories: ["research", "creative"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# Swin-Tiny Correctly Classified 92.4% of Lung CT Slices, EfficientNet-B0 Got 83.2%

> **Краткая суть (BLUF):** 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.  • Swin-Tiny trained for 85.6 min (27.5M parameters), EfficientNet-B0 for 44.4 min (4M) • Adenocarcinoma was confused with squamous cell carcinoma in 17% of cases (EfficientNet) and 15% (Swin) • Double brightness normalization turned the image almost uniformly gray, and the network did not learn

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.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1110294/?utm_campaign=1110294&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/16494
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
