CNN vs. Transformer:基於醫學影像的深度學習模型在影像任務中的全面比較與分析
CNN vs. Transformer: A Comprehensive Comparison and Analysis of Deep Learning Models for Medical Imaging Tasks
摘要
隨著深度學習技術在醫學影像分析領域的快速發展,卷積神經網路(Convolutional Neural Network, CNN)與自注意力機制(Transformer)已成為影像分類、語意分割與物件偵測等任務的主流架構。CNN 擅長擷取區域性特徵,具備良好的運算效率與結構穩定性;Transformer 則憑藉其全域建模能力與高度彈性,在部分任務中展現出優異表現。然而,兩者在不同影像任務與資料特性下的實際效能仍缺乏系統性比較與分析。
本研究以 VinBigData Chest X-ray(胸腔 X 光)與 Kvasir-SEG(大腸鏡影像)兩組醫學影像資料集為基礎,針對多標籤分類、語意分割與物件偵測三項任務,全面評估 CNN 與 Transformer 架構於效能、資源使用、特徵表徵能力與對抗穩健性等層面的差異。評估指標包括 Accuracy、F1-score、Jaccard index、mIoU 與 mAP,計算效率則以模型參數量、FLOPs 與記憶體佔用為準。進一步透過 Centered Kernel Alignment(CKA)與 Projected Gradient Descent(PGD)實驗,深入探討模型內部特徵學習行為與對抗擾動下的穩健性表現。
實驗結果顯示,CNN 架構於分類與中小型語意分割任務中表現穩定,尤其適用於結構細緻、對比低或樣本不平衡的影像資料;而以 DETR 為代表的 Transformer 架構,則於物件偵測任務中展現出優異的語意一致性與對抗擾動下的穩健性,較適合需整合全域上下文資訊之應用場景。CKA 分析指出,CNN 層間表徵具明確模組邊界,表徵分區穩定,有利於模型剪枝與壓縮;相對地,Transformer 各層表徵具高度聚合性,顯示其潛藏語義一致性與中層蒸餾潛力。
此外,研究指出,影像資料的紋理與輪廓特性,以及資料集規模,對模型選擇具有關鍵影響。未來可進一步發展 CNN–Transformer 混合架構、語義一致性轉換模組與任務導向的特徵精煉策略,以提升模型整體效能與泛化能力。
本研究提出一套跨任務、跨模型之比較分析框架,作為醫學影像領域選擇與部署深度學習模型的實用依據。
本研究以 VinBigData Chest X-ray(胸腔 X 光)與 Kvasir-SEG(大腸鏡影像)兩組醫學影像資料集為基礎,針對多標籤分類、語意分割與物件偵測三項任務,全面評估 CNN 與 Transformer 架構於效能、資源使用、特徵表徵能力與對抗穩健性等層面的差異。評估指標包括 Accuracy、F1-score、Jaccard index、mIoU 與 mAP,計算效率則以模型參數量、FLOPs 與記憶體佔用為準。進一步透過 Centered Kernel Alignment(CKA)與 Projected Gradient Descent(PGD)實驗,深入探討模型內部特徵學習行為與對抗擾動下的穩健性表現。
實驗結果顯示,CNN 架構於分類與中小型語意分割任務中表現穩定,尤其適用於結構細緻、對比低或樣本不平衡的影像資料;而以 DETR 為代表的 Transformer 架構,則於物件偵測任務中展現出優異的語意一致性與對抗擾動下的穩健性,較適合需整合全域上下文資訊之應用場景。CKA 分析指出,CNN 層間表徵具明確模組邊界,表徵分區穩定,有利於模型剪枝與壓縮;相對地,Transformer 各層表徵具高度聚合性,顯示其潛藏語義一致性與中層蒸餾潛力。
此外,研究指出,影像資料的紋理與輪廓特性,以及資料集規模,對模型選擇具有關鍵影響。未來可進一步發展 CNN–Transformer 混合架構、語義一致性轉換模組與任務導向的特徵精煉策略,以提升模型整體效能與泛化能力。
本研究提出一套跨任務、跨模型之比較分析框架,作為醫學影像領域選擇與部署深度學習模型的實用依據。
With the rapid advancement of deep learning in medical image analysis, convolutional neural networks (CNNs) and self-attention-based Transformers have become dominant architectures for image classification, semantic segmentation, and object detection. CNNs are well-suited for capturing local patterns and offer computational efficiency and structural stability. In contrast, Transformers exhibit strong global modeling capacity and architectural flexibility, achieving competitive performance in certain tasks. However, a systematic comparison of their performance across different tasks and datasets remains insufficient.
This study conducts a comprehensive evaluation of CNN and Transformer architectures using two medical imaging datasets: VinBigData Chest X-ray and Kvasir-SEG. Three major tasks—multi-label classification, semantic segmentation, and object detection—are examined in terms of predictive performance, computational cost, representational characteristics, and adversarial robustness. Evaluation metrics include Accuracy, F1-score, Jaccard index, mean Intersection over Union (mIoU), and mean Average Precision (mAP), while computational efficiency is assessed based on the number of parameters, FLOPs, and memory usage. To further explore model behavior, we employ Centered Kernel Alignment (CKA) and Projected Gradient Descent (PGD) to analyze internal feature representations and robustness under adversarial perturbations.
Experimental results demonstrate that CNNs consistently perform well in classification and small-to-medium-scale segmentation tasks, particularly for medical images with fine structures, low contrast, or class imbalance. On the other hand, Transformer-based models, such as DETR, excel in object detection tasks, showing superior semantic consistency and robustness, especially when global context modeling is essential. CKA analysis reveals that CNNs exhibit distinct modular boundaries across layers, making them favorable for pruning and compression, while Transformers display high inter-layer representational similarity, suggesting potential for semantic consistency and intermediate-layer distillation.
Moreover, the study highlights that both the texture-contour characteristics and the scale of the dataset play a critical role in model selection. Future research directions may involve designing hybrid CNN–Transformer architectures, developing semantic alignment modules, and task-specific feature refinement strategies to enhance model performance and generalizability.
This work proposes a unified cross-task and cross-architecture comparison framework to support more precise selection and deployment of deep learning models in medical image analysis.
This study conducts a comprehensive evaluation of CNN and Transformer architectures using two medical imaging datasets: VinBigData Chest X-ray and Kvasir-SEG. Three major tasks—multi-label classification, semantic segmentation, and object detection—are examined in terms of predictive performance, computational cost, representational characteristics, and adversarial robustness. Evaluation metrics include Accuracy, F1-score, Jaccard index, mean Intersection over Union (mIoU), and mean Average Precision (mAP), while computational efficiency is assessed based on the number of parameters, FLOPs, and memory usage. To further explore model behavior, we employ Centered Kernel Alignment (CKA) and Projected Gradient Descent (PGD) to analyze internal feature representations and robustness under adversarial perturbations.
Experimental results demonstrate that CNNs consistently perform well in classification and small-to-medium-scale segmentation tasks, particularly for medical images with fine structures, low contrast, or class imbalance. On the other hand, Transformer-based models, such as DETR, excel in object detection tasks, showing superior semantic consistency and robustness, especially when global context modeling is essential. CKA analysis reveals that CNNs exhibit distinct modular boundaries across layers, making them favorable for pruning and compression, while Transformers display high inter-layer representational similarity, suggesting potential for semantic consistency and intermediate-layer distillation.
Moreover, the study highlights that both the texture-contour characteristics and the scale of the dataset play a critical role in model selection. Future research directions may involve designing hybrid CNN–Transformer architectures, developing semantic alignment modules, and task-specific feature refinement strategies to enhance model performance and generalizability.
This work proposes a unified cross-task and cross-architecture comparison framework to support more precise selection and deployment of deep learning models in medical image analysis.
所屬典藏
數據科學與工程研究所引用此條目
Wen, B.-X. (2025). CNN vs. Transformer: A Comprehensive Comparison and Analysis of Deep Learning Models for Medical Imaging Tasks. https://thesis.lib.nycu.edu.tw/handle/20.500.14371/85584
引用文字依 APA 第 7 版格式自動產生,使用前請再核對。
分享
永久網址:https://thesis.lib.nycu.edu.tw/handle/20.500.14371/85584