The Early Detection Imperative. Lung cancer remains one of the leading causes of cancer-related deaths worldwide, and early, accurate detection is critical for improving patient outcomes. Traditional machine learning (ML) models have shown limited ability to generalize from training data to real-world clinical settings -- a fundamental limitation that restricts their practical usefulness despite impressive performance on benchmark datasets.
Deep Learning's Promise in Medical Imaging. Advances in deep learning and artificial intelligence have transformed lung cancer detection by enabling accurate analysis of CT scan images. AI-based models can predict individual cancer risk, facilitate precise diagnosis, support personalized treatment planning, and enhance prognostic assessment. The integration of ML with CT imaging allows for data-driven clinical decision support that goes beyond what radiologists can achieve manually.
The Role of Transfer Learning. Transfer learning is a technique that applies knowledge learned from solving one problem to a different but related task. In medical imaging, this means using deep neural networks pre-trained on large image datasets to extract meaningful features from CT scans without requiring enormous amounts of medical training data. ResNet (Residual Network) architectures have been extensively used for tumor recognition and classification in lung cancer, glioblastoma, and other diseases.
Study Objective. This study aimed to develop a two-stage deep learning model using a ResNet50 backbone within a U-Net architecture to first segment lung tumor regions from CT scans, then classify images as cancerous or noncancerous. The key innovation was testing this model on an independent real-world clinical dataset from Hazrat Rasool Hospital in Iran -- data completely unseen during training -- to assess true clinical generalizability.
Stage 1 -- Tumor Segmentation with U-Net. The first task was tumor localization. The ResNet50 model's final layer was removed and replaced with 5 upsampling layers and 11 convolutional layers, creating a decoder that mirrors ResNet50 as the encoder -- forming a U-Net architecture. This model was trained to reconstruct only the tumor and lesion positions from CT scan images. Training used a combination of binary cross-entropy loss and Dice loss functions, which together provided more stable and generalizable learning than either loss alone.
Stage 2 -- Cancer Classification with MLP. After the segmentation model was trained, its encoder was frozen (parameters locked). The encoded feature representations were extracted and fed into a two-layer Multi-Layer Perceptron (MLP) with 512 and 256 neurons, ReLU activation, and a 0.3 dropout rate. The MLP was trained separately to perform binary classification between cancerous and normal CT images. This two-stage design ensured that features learned for tumor localization directly informed the classification task.
Training Data and Augmentation. The segmentation task used 2,535 lung CT images including cancer, COVID-19, and infectious disease cases. The classification task used a combined dataset of 1,346 cancerous and 506 normal CT images. Data augmentation included rotation, width and height shifts, shearing, zooming, and horizontal flipping. Dropout layers and regularization helped prevent overfitting. The model was trained over 30 epochs with an Adam optimizer using a very small learning rate (1e-8) to preserve pre-trained ResNet50 features.
Real-World Clinical Validation. The model's true test was an independent dataset of CT scans from 72 lung cancer patients at Hazrat Rasool Hospital in Iran -- data never seen during training. This external clinical validation is critical because it tests whether the model actually generalizes to new patient populations and imaging environments, rather than merely memorizing patterns in training data.
Strong Performance on Real Patient Data. The deep learning model achieved 96% accuracy on the validation set and 94% accuracy on the real-world clinical test set from Hazrat Rasool Hospital. Multiple evaluation metrics confirmed robustness: F1 score, Matthews Correlation Coefficient (MCC), Cohen's kappa, and Dice index all demonstrated strong diagnostic reliability. The ROC curve results on real patient test data further confirmed the model's sensitivity and specificity on previously unseen data.
Traditional ML Models Completely Failed on External Data. The comparison with traditional ML classifiers -- Support Vector Machine (SVM), XGBoost, Naive Bayes (NBC), and K-Nearest Neighbor (KNN) -- revealed a critical generalization failure. While all traditional models achieved 99-100% accuracy on training and validation data, they all scored approximately 0.51 accuracy on the external test set -- essentially random guessing. Cohen's kappa, MCC, and F1 scores were all zero for SVM, XGBoost, NBC, and KNN on the external dataset.
Segmentation Task Results. The U-Net segmentation model achieved a best Binary Cross-Entropy loss of 0.3 and Dice loss of 0.34 on the validation set. Visual inspection of model outputs on five test samples demonstrated the model's ability to accurately reconstruct tumor regions from CT scan images. The segmentation capability is particularly valuable for assisting radiologists in locating small nodules and lesions in challenging lung regions where missed diagnoses are most likely.
ResNet50 Outperforms Competing Architectures. Comparative experiments tested multiple encoder architectures: VGG19 achieved 92.1% accuracy, Xception 93.0%, InceptionV3 94.4%, DenseNet121 91.4%, and EfficientNetB0 94.6%. ResNet50 achieved 94% accuracy -- competitive with the best-performing architectures. ResNet's residual connections, which prevent the vanishing gradient problem, provide an advantage in extracting deep features from complex CT scan data.
Significance of Generalization. The study's most important finding is not just that the deep learning model achieved high accuracy, but that it maintained that accuracy on completely independent real-world clinical data. The near-zero performance of traditional ML on external data is a systemic problem -- these models overfit to training dataset characteristics rather than learning generalizable features of lung cancer. This generalization gap has been a major barrier preventing ML adoption in real clinical settings.
Comparison with Prior AI Research. The model's performance aligns with leading prior studies. Ardila et al. reported an AUC of 0.94 for CT-based lung cancer detection. Schwyzer et al. achieved 95.9% sensitivity and 98.1% specificity using FDG-PET combined with deep learning. Shen et al.'s multiscale CNN for lung nodule classification achieved 88.84% accuracy. This study's 94% classification accuracy, driven by features from the segmentation task, compares favorably to these benchmarks while adding tumor localization capability.
Inference Speed for Clinical Use. The U-Net segmentation model processes each CT scan in 23 milliseconds of GPU time, while the MLP classifier adds 2.5 milliseconds per image. This speed is clinically relevant -- a model that takes minutes per scan would not integrate well into radiology workflows, but millisecond inference enables real-time assistance during image review. The computational efficiency was achieved using an NVIDIA T4 Tensor Core GPU.
Supporting Rather Than Replacing Radiologists. The primary goal of the study was explicitly to assist physicians in detecting lung nodules, not to replace radiologists. By localizing lesion regions in CT scans, the model serves as a second-reader tool that can reduce missed diagnoses, particularly for small nodules in challenging anatomical locations. This assistive framing is important for clinical acceptance and regulatory pathway.
Current Limitations. The study acknowledges several important limitations. The external clinical test set contained only 72 patients, which limits statistical confidence in generalizing findings to broader populations. The model was trained on retrospective datasets rather than prospectively collected clinical data, which may not fully capture the variability in real-world imaging environments. Greater diversity in CT scan sources, patient demographics, and imaging equipment would strengthen generalizability claims.
The Need for Explainability. For AI tools to integrate into routine diagnostic workflows, clinicians must understand how decisions are made. The current model focuses on classification accuracy and lesion localization without providing insight into the specific image features driving its decisions. Future iterations should incorporate explainability techniques such as Grad-CAM (Gradient-weighted Class Activation Mapping) or SHAP (SHapley Additive exPlanations) to make the model's reasoning transparent to radiologists.
Multimodal Data Integration. The current model is limited to CT scan images. Future models could incorporate clinical variables such as patient history and symptoms, genomic data from tumor biopsies, and other imaging modalities. Combining imaging with molecular data would enable more comprehensive, patient-specific diagnostic and treatment decisions. A reinforcement learning pipeline could also continuously improve the model as it encounters new cases in clinical practice.
Regulatory and Ethical Pathways. Clinical deployment requires navigating regulatory frameworks including FDA approval in the United States, EMA requirements in Europe, and data protection compliance under HIPAA and GDPR. Future development phases must proactively address these requirements, along with prospective clinical trials, subgroup analyses across demographic groups, and integration protocols for hospital information systems.
Core Contribution. This study demonstrates that a deep learning framework using transfer learning with ResNet50 within a U-Net architecture can reliably detect and localize lung tumors in CT scans with 94% accuracy on real-world clinical data. More importantly, it demonstrates that traditional ML models -- despite achieving near-perfect training performance -- completely fail when tested on independent clinical data, revealing a fundamental limitation that has likely affected many published ML studies.
The Two-Stage Advantage. The separation of tumor segmentation and cancer classification into two sequential tasks proved particularly effective. By first training the model to localize tumor regions and then using those learned features for classification, the approach leverages complementary information. The segmentation task forces the model to learn spatially meaningful features directly relevant to tumor identification, which then enables more accurate and interpretable classification.
Path to Clinical Integration. The model shows strong potential for real-world clinical application as a decision support tool for radiologists. Its high speed (25.5 milliseconds per image), strong accuracy metrics, and demonstrated generalization on an independent hospital dataset position it as a viable candidate for integration into diagnostic workflows. The next steps -- prospective validation, interpretability enhancements, and regulatory compliance -- form a clear roadmap toward clinical deployment.