Non-Invasive Risk Stratification of Advanced Liver Fibrosis from Ultrasound Images Using Swin Transformer
Abstract
Advanced liver fibrosis is associated with poorer prognosis and a greater need for surveillance, referral, and treatment planning, making its identification a clinically meaningful goal in chronic liver disease. Although deep learning has shown promise for ultrasound-based fibrosis analysis, prior work has focused on full-stage CNN and radiomics pipelines, and transformer-based architectures remain underexplored for clinically actionable binary risk stratification. This study evaluates a Swin Transformer specifically designed for binary rather than multi-class fibrosis classification from conventional B-mode ultrasound images. A publicly available dataset of 6,323 images was used; because the data originate from a single retrospective source with an uneven stage distribution, class imbalance and single-source variability were explicitly addressed. The original five-stage labels were reformulated as a binary task, grouping F0-F2 as non-advanced and F3-F4 as advanced fibrosis, which more closely reflects real-world screening and triage pathways. Preprocessing included RGB conversion, resizing to 224 × 224 pixels, ImageNet normalization, and mild training-set augmentation. A pretrained Swin Tiny backbone with a binary classification head was trained using a freeze-unfreeze fine-tuning strategy with positive-class-weighted loss. On the held-out test set, the model achieved an accuracy of 0.9842, a balanced accuracy of 0.9830, an F1-score of 0.9804, and an ROC-AUC of 0.9953. Threshold analysis and temperature scaling yielded only marginal additional benefit. Because validation was internal on a single-source dataset with image-level splitting, the findings should be interpreted as evidence of internal feasibility rather than proof of broader clinical generalizability; external multicenter validation remains essential.