HybridMedNet: An Efficient Deep Learning Framework Based on CNN–Transformer Architecture for Benign and Malignant Thyroid Nodule Classification Using Ultrasound Images
Abstract
Thyroid nodule assessment often involves ultrasound imaging, but differentiating benign from malignant nodules remains challenging due to image noise, acquisition variations, and subtle visual differences. Convolutional neural networks (CNNs) effectively learn local image features, but their restricted receptive fields may limit their ability to model long-range spatial relationships. Vision Transformers provide a global perspective by modeling the entire image, but typically require larger training sets, making them less suitable for data-scarce medical imaging applications. To address these limitations, this paper introduces HybridMedNet, a compact CNN–Transformer architecture for thyroid nodule classification in ultrasound images. The proposed architecture integrates a convolutional stem, channel-wise feature recalibration using Residual Squeeze-and-Excitation blocks, a six-layer Transformer encoder for global representation learning, and learned attention pooling for classification. Experiments used the official 7:1:2 train–validation–test split of the TN5000 thyroid ultrasound dataset. The model was trained with AdamW using cosine learning-rate scheduling, warmup, Mixup, label smoothing, class-weighted loss, and test-time augmentation. HybridMedNet was compared with ResNet-18, ResNet-50, and MobileNet-V2 using the same dataset partition. On the 1,000-image test set, HybridMedNet achieved an accuracy of 0.90, macro-F1 score of 0.90, and AUC of 0.95, outperforming the evaluated baselines with approximately 3.3 million trainable parameters. Grad-CAM visualizations showed that the model primarily focused on thyroid gland regions. These results demonstrate the feasibility of combining local convolutional representation with global Transformer-based reasoning for compact thyroid ultrasound classification. Further evaluation using multiple random seeds, independent datasets, statistical significance testing, and clinically aligned multi-class classification is required to establish generalizability and clinical applicability.