Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2025 Dec 6;16:1441. doi: 10.1038/s41598-025-31000-6

A novel two-stage deep learning approach for lung cancer using enhanced ResNet50 segmentation and LungSwarmNet classification

Kalaipriya Omprakash 1,, Dhandapani Samiappan 2
PMCID: PMC12796376  PMID: 41353462

Abstract

One of the leading killers globally now is lung cancer. It ranks high among the dangerous malignant tumors that people may have. It is the leading cause of cancer-related fatalities in both men and women globally, and its mortality rate is higher than that of any other malignant tumor. Medical image segmentation has seen the successful use of many deep learning framework-based techniques in recent years. The use of computer tomography (CT) has increased in the detection of lung cancer, a significant malignancy. Patients with lung cancer have a better chance of surviving if the disease is detected early. Early diagnosis allows professionals to deliver appropriate therapy within a specific period, which in turn reduces the fatality rate. The healthcare industry benefits greatly from the advanced services deep learning models offer. In this study, we present a deep neural network architecture named as lung swarm net that combines DenseNet201 with PSO to classify lung cancer from CT scans of the lung. We used ResNet50 for the segmentation procedure and DenseNet-201 with Particle Swarm Optimization (PSO) for the classification in order to identify lung cancer. According to the experimental data, the suggested model outperforms other current models in terms of accuracy.

Keywords: Lung cancer, Segmentation, Classification, ResNet50, CNN, DenseNet-201, PSO

Subject terms: Cancer, Computational biology and bioinformatics, Mathematics and computing, Medical research, Oncology

Introduction

Malignant lung cancer is the leading cause of cancer-related mortality worldwide. With a 5-year survival rate below 20%, individuals with this condition have a very poor prognosis. A late diagnosis is the main reason why most patients do not have a good prognosis1. Worldwide, lung cancer accounts for over 1.8 million new cases annually, 1.6 million deaths (19.4 percent of all cancers), and a dismal 18% 5-year survival rate2.About one million new cases of cancer are recorded annually, according to the World Health Organization (WHO). Many different regions of the body are susceptible to cancer development, including the lungs, breasts, colon, and prostate. There are several potential causes of cancer, including genetics, exposure to toxins, unhealthy lifestyle choices, and environmental factors. Polish lung cancer rates increased in 2019. With 9.9% of women and 16.1% of men afflicted, lung cancer affects around 20% of the country’s population. Among the many prevalent illnesses and major killers, lung cancer ranks high. Smoking, both active and passive, is a known carcinogen for the lungs. While smoking is a known risk factor for lung cancer, it is not the only one. Lung cancer is one of the leading causes of mortality and an extremely common condition. Cancer of the lung often develops in the glands of the lungs or the bronchial tubes. During their growth and metastasis, cancer cells significantly damage the patient’s respiratory system by blocking oxygen exchange. Exposure to secondhand smoke on a regular basis increases the risk of developing lung cancer. While smoking is a known risk factor for lung cancer, it is not the only one. Additional risk factors include asbestos exposure, air pollution, family history, and certain viral infections such as the human papillomavirus (HPV)3.

A pathologist can detect and classify cancer cells based on their cell types. Histological classifications might be used to classify the different kinds of lung malignancies. There are two types of lung cancer: small cell lung cancer (up to 15% of cases) and non-small cell lung cancer (85% of cases). Lung adenocarcinoma, large cell carcinoma, and squamous cell lung cancer are the three primary subtypes of non-small cell lung cancer (NSCLC). Squamous cell carcinoma, often known as lung adenocarcinoma, is shown in Fig. 1. Microscopically, cancer cells seem different in lung adenocarcinoma, which starts in glandular cells that secrete mucus and grows in smaller airways like alveoli. The periphery of the lungs is the usual location for lung adenocarcinoma. Adenocarcinoma of the lung develops at a slower rate than its other subtypes. Cancer of the squamous cell lung begins in these cells. These are microscopic, flat cells that, under magnification, look like fish scales. They encase the airways of the lungs. A alternative name for squamous cell lung cancer is epidermoid carcinoma4. Lung cancer often falls into one of two categories: small cell lung cancer (SCLC) or non-small cell lung cancer (NSCLC). SCLC makes up around 15–20% of all instances of lung cancer. There is a significant negative effect on patients’ physical and emotional health due to SCLC’s high malignancy, quick progression, early metastatic dissemination, and bad prognosis5.

Figure.1.

Figure.1.

Lung Adenocarcinoma, Large Cell Carcinoma and Squamous cell lung carcinoma.

One promising strategy to decrease lung cancer 10 mortality is early diagnosis. At now, early detection accounts for 15% of lung cancer diagnoses, allowing for a 16% five-year survival rate. Patients with lung cancer have a poor prognosis for two primary reasons: (1) the lack of symptoms makes early detection difficult, and (2) the illness is more difficult to treat after it has progressed. Stages III and IV are present in the majority of individuals with 15 cases of lung cancer, accounting for 30% and 40% of cases, respectively6.

At the moment, a Computed Tomography (CT) scan of the lungs is among the main tools for evaluating and detecting lung cancer in its early stages. Experts in radiology and pulmonary medicine may use CT scans to spot suspected lumps or tumors and assess their kind, size, location, condition, and stage. To accurately diagnose lung cancer and arrange therapy, CT-Scan techniques provide clinicians with crucial information. However, due to the high degree of knowledge and time commitment involved, accurate diagnosis of lung cancer using CT scans is challenging and time-consuming7. In order to enhance survival rates and detect lung cancer earlier, computed tomography (CT) scans should be used for therapy, monitoring, and analysis. It is crucial to accurately segment lung nodules while using this method, since it will directly impact the analytical findings. There is significant therapeutic importance in developing a reliable automated segmentation model to prevent laborious manual treatment and to decrease diagnostic discrepancy among clinicians, especially given the rising amount of CT scans8.

In transfer learning, models learned on one issue are used as a foundation for a related problem. Being flexible, it lets you utilize pre-trained models as feature extraction preprocessing alone or incorporate them into new models altogether. This experiment involves superimposing a newly-defined classifier that differentiates between three groups onto the pre-trained model. Some of the best and most consistent architectures for detecting cancer from lung scans have been MobileNet, VGG16, VGG19, DenseNet-201, and ResNet-101; this study compares and contrasts their performance9.

Models based on deep learning have shown better skills in autosegmentation of medical images since its introduction. Autonomously completing segmentation tasks, deep learning models learn feature representation and use the acquired high-dimensional abstraction. Various automated segmentation strategies for lung cancer based on deep learning have been suggested in recent research10. One deep learning architecture that has shown promise in several image-related tasks, including medical image analysis, is DenseNet, which stands for Densely Connected Convolutional Networks. Medical computed tomography (CT) scans and histopathological images used for cancer diagnosis are successfully processed by it because of its distinctive structure and features11. In our work, DenseNet was used for segmentation.

Lung image analysis begins with CT image classification. The importance of algorithms for categorization becomes more clear when considering the closeness of various gray levels in soft tissues, the intensity of homogeneity, and artifacts12. In 2016, the Residual Network (ResNet) was created by a team of academics (He et al., 2016). One effective CNN framework is ResNet. An novel solution to the vanishing gradient issue was found via the “identity shortcut connection,” which enables one or more levels to be bypassed by feeding activation from one layer to another13. This research describes the use of ResNet for segmentation and DenseNet for classification of images containing lung cancer.

Related work

In this section, we researched about various techniques that can be used for lung cancer detection.

Abdul RahamanWahabSait et al.14 used the DL approach to construct a model for LC detection. In order to make the suggested LC detection model work better, it used methods for preprocessing and augmenting images. To eliminate artifacts and noise, the SyN function and Retinex filters were used. To make the dataset bigger, we employed the GANs method. The author created a model for extracting important characteristics using DenseNet-121. To decrease the feature count while preserving critical information, a deep autoencoder model was used.

Abdul Qayyum et al.15 offered a ResNet-based 3D model that incorporates the ASPP and PE modules in order to segment four organs located in the chest. When tested on the SegTHOR2019 dataset, the suggested model outperformed the state-of-the-art deep learning models while using less GPU RAM. In terms of esophageal, cardiac, tracheal, and aortic segmentation, the testing findings demonstrated that the suggested model effectively generated superior performance. For therapeutic purposes, the suggested model may be superior to others when it comes to identifying and segmenting organs at risk in the vicinity of lung cancer.

Hybrid genetic algorithms were used by Arthi et al.16 to optimize certain parameters for better performance. This was achieved by weighted parameter calculation, which led to refined sets of parameters. Using Instantaneously Trained DenseNet techniques and hybrid genetic algorithms, they suggested a strategy for predicting lung cancer. Following optimization, they trained and classified retrieved characteristics using hybrid classifier algorithms, which helped diagnose lung nodules as benign or malignant with remarkable precision—achieving an accuracy of up to 96.54%.

A new method for using the PSD for feature selection in digital images was introduced by IbomoiyeDomorMienye et al.17. An alternative to the L2 linear operator, a nonlinear operator, was suggested for choosing the collection of basis functions. The L2 regularization method outperformed the dropout and hidden layer expansion techniques when applied to DenseNet as an optimization. The findings show that the best performance was achieved by combining the improved PSD methodology for sparse images with the increased capability of DenseNet, as compared to other approaches.

To improve DL characteristics for lung cancer prediction, Saurabh Singh Raghuvanshi et al.18 presented a novel strategy that combines PSO and BO techniques. They found that the model’s accuracy and reliability were much improved by using both methods. Optimal configurations were the result of the integration’s efficient search and exploitation of hyperparameters. The significance of fine-tuned parameters in lung cancer diagnosis was shown by the performance enhancement that resulted from them. The study’s findings might greatly benefit radiologists in their ability to detect lung cancer early on, which could lead to better clinical results and lower death rates. For histopathology images, the model performed well with a 99.5% accuracy rate, 98.3% precision, 99.2% recall, 99.4% F1-score, and 1.19% error rate.

Kalaivani et al.19 searched the data for related traits and used them to speed up learning.It makes use of the input’s spatial coherence. Prior to training and testing, images undergo pre-processing, which includes selecting and extracting features. The result will be shown after the training and testing parts of the CNN algorithm have been completed. The algorithm will then determine whether the input lung image is normal or abnormal.

A ResNet50 based lung image segmentation model was shown by Varun Biyyala et al.20, which demonstrated the potential of deep learning in precisely defining lung structures, with a high Dice score. Accurate localization is critical in clinical applications, and although the model shows competency, additional enhancements are required.

A technique for segmenting MRI, CT, and ultrasound images was suggested by Asuntha et al.21. By comparing the two images with the relevant characteristics extracted from each, cancer cells may be accurately identified. They also use ultrasound images to check whether their method is legitimate. They also employed feature selection using the PSO, GO, and SVM algorithms, which reduced false positives and increased accuracy to about 89.5%.

For the purpose of lung nodule cancer classification, Juan Lyu et al.22 presented multi-level cross ResNet, a new deep learning computational architecture. Both binary classification, with benign and malignant classifications, and ternary classification, with benign, indeterminate, and malignant categories, were explored. In order to enhance performance in binary and ternary classifications, the evaluation findings demonstrate that the multi-level and cross residual structures aid in extracting multi-scale features and fusing them.

A semi-automatic method for obtaining the ground truth for every lung was introduced by YeganehJalali et al.23. With this technology, you can intelligently generate all mask images without a radiologist’s help, which saves a ton of time and is one of the many advantages. Secondly, they found that effective network input imagery significantly reduced the false positive rate and increased dice coefficients, and they suggested a new three-image channel generation. Last but not least, they used a pre-trained ResNet-34 encoder in a BCDU-Net, a unique deep network architecture, to build the segmentation framework.

Zhitao Xiao et al.24 successfully executed multi-layer feature extraction by employing a 3D-Res2UNet network to decompose and fuse the input. It enhances the network’s segmentation accuracy, allowing it to better differentiate between lung nodule edges and other non-relevant tissues. The second reason to include the 3D-Res2Net module twice during downsampling is to take advantage of multi-level information complementarity. The multi-layer detection network may gradually fill in the gaps left by the preceding layer’s missing target points by continuously expanding the feature map. This leads to improved outcomes.

Summary:

  • Because the lungs are so big, lung cancer typically goes undiagnosed until late stages. This is why early detection is so important.

  • For effective feature segmentation, high-quality medical pictures are very important since noise and artifacts may make models work less well.

  • CNNs, particularly DenseNet, proficiently extract and categorize characteristics from lung images for nodule detection.

  • Techniques like GANs, PSO, BO, and genetic algorithms for preprocessing, data augmentation, and optimization make models more accurate and reliable.

  • Methods for extracting features at many levels and scales (such 3D-Res2UNet, BCDU-Net, and cross ResNet) make segmentation better, cut down on false positives, and help find lung cancer more reliably.

Proposed method

With an 18% five-year survival rate, lung cancer is both frequent and devastating. To enhance survival rates and detect lung cancer earlier, computed tomography (CT) scans should be used for therapy, monitoring, and analysis. Precise segmentation of lung nodules is crucial with this method since it impacts the outcomes of the study that follows. The need for a reliable automated segmentation model is growing in the clinical community as the volume of CT images continues to rise; this will help physicians save time and cut down on diagnostic bias8.To segment and classify lung cancer from CT scans of the lung, we present here a deep neural network design. As seen in Fig. 2, we used ResNet50 for the segmentation procedure and DenseNet with Particle Swarm Optimization (PSO) for the classification in order to identify lung cancer.

Fig. 2.

Fig. 2

Block Diagram of proposed model.

  • i.

    Image Dataset

In this case, the dataset was examined using the suggested approach using Three dataset from Kaggle source.

There are 1190 CT scan pictures of 110 patients in the IQ-OTH/NCCD Lung Cancer Dataset (https://www.kaggle.com/datasets/adityamahimkar/iqothnccd-lung-cancer-dataset), and they are divided into normal, benign, and malignant groups. There are 561 malignant, 120 benign, and 416 normal photos in the training set. There are 197 images in the test set. Radiologists have marked up the scans, which are in DICOM format and include a different number of slices for each instance.

The Chest CT-Scan Images Dataset (https://www.kaggle.com/datasets/mohamedhanyyy/chest-ctscan-images) comprises JPG and PNG CT scans that are categorized into four groups: Adenocarcinoma, Large Cell Carcinoma, Squamous Cell Carcinoma, and Normal. The data is divided into three sets: 70% for training, 20% for testing, and 10% for validation. The folder structure is straightforward. Adenocarcinoma, for instance, comprises 195 training photos, 120 test images, and 23 validation images.

The Lung Cancer Detection LIDC-IDRI Subset (https://www.kaggle.com/datasets/busharakmea/lung-cancer-detection-lidc-idri-subset ) has CT scan ROIs that are marked as either benign or malignant. There are 650 benign and 673 malignant photos in the training set, 203 and 210 in the testing set, and 162 and 168 in the validation set. Data that has been labeled by experts may help with binary classification for finding cancer.

  • ii.

    Image Preprocessing

To facilitate image categorization and improve image quality and relevance before further processing and analysis, this pre-processing step is implemented.

Rescaling: The resizing method tries to resize the image by changing the image size variable and specifying the desired size for the image to be scaled. The image is resized by making a linear adjustment to the scale. An image assignment with a value between 0 and 1 is guaranteed by the computation of this linear transformation3.

Contrast enhancement: Use contrast enhancing methods to make the lung modules more visible.

Normalization: Get the pixel values normalized such that they all have a mean of 0 and a standard deviation of 1.

Data Augmentation: To make datasets more diverse and large, use data augmentation techniques like flipping, rotating, and zooming.

  • iii.

    ResNet50 Segmentation

The exponential growth in computer power and data storage has propelled deep learning, a branch of AI, to the forefront of automated image segmentation. Some examples of deep learning models that are able to capture more complicated patterns as the network depth grows include U-Net topologies, fully convolutional networks (FCNs), and convolutional neural networks (CNNs). To train, these networks repeatedly traverse input data and, using hidden layers in a hierarchical fashion, extract features10.

Activation functions, pooling layers, and convolutional layers are the main components of a convolutional neural network (CNN). The feature maps produced by convolutional layers are connected to their respective regions in the preceding layer by the kernel weights. This is achieved by applying convolutional kernels to the input images. By lowering the feature maps’ resolution, pooling layers collect local spatial information, leading to more compact feature representations. Incorporating non-linearity, activation functions enable the network to represent intricate patterns25.

The ResNet design uses residual blocks given in Fig. 3 to address the problem of accuracy loss that happens while training extremely deep networks. Residual blocks prioritize learning the easier-to-optimize residual mapping F(x) = H(x)—x over learning the underlying mapping H(x). Following this, we calculate the ultimate output of a residual block as H(x) = F(x) + x1.

graphic file with name d33e460.gif 1

Fig. 3.

Fig. 3

Skip connection and residual block.

graphic file with name d33e474.gif 2

The network closes in on an identity mapping where H(x) ≆ x as F(x) gets closer to zero. In reality, the network may modify the feature dimensions using convolutional residual blocks, which add convolution operations along the residual branch, without drastically changing the advantages of identity mapping25,26.

Our suggested approach to lung cancer segmentation makes use of a three-part hybrid encoder-decoder network:

A ResNet50 encoder that takes CT scans as input and uses them to create feature representations in a hierarchical fashion.

Following the encoder is an Atrous Spatial Pyramid Pooling (ASPP) module that uses parallel dilated convolutions with variables in dilation rates to collect multi-scale contextual information. In this way, the network is able to learn to partition lesions of varied sizes by including both small-scale local information and larger contextual variables. The ASPP module’s multi-scale feature maps are progressively upsampled to the original resolution via a decoder that takes inspiration from U-Net. Restoring spatial information lost while downsampling is made possible by skip connections from older encoder levels to comparable decoder layers. To finish off the segmentation process, the network’s top layer has an average pooling layer, two sigmoid-activated outputs, and a fully connected layer. Automated lung lesion segmentation of high speed and accuracy is achieved by this design, which successfully integrates ResNet50’s deep feature extraction capabilities, ASPP’s multi-scale aggregation, and a U-Net decoder’s exact spatial reconstruction.

  • iv

    LungSwarmNet for classification

For the purpose of classifying lung cancer cases, we used DenseNet in conjunction with Particle Swarm Optimization (PSO). DenseNet is a convolutional neural network (CNN) variant that guarantees optimal data flow across network layers by virtue of its densely feature-connected architecture. Contrary to traditional CNN design, which alternates between convolutional and pooling layers, DenseNet builds on ResNet’s idea by linking the front layers of each layer in a dense block. There is an increasing degree of hierarchy in the network topologies. In a thick block, the layers are tightly packed together. The feature propagation may be strengthened by this neural network construction, which increases the flow of information and gradients across the network27.

DenseNet-201 is a deep convolutional neural network with 201 layers. It is possible to import a pre-trained network model from the ImageNet database, which has been trained using more than one million images. A large variety of animals, as well as keyboards, mouse, and pencils, are among the thousand object categories that the pre-trained model can identify. The network has successfully trained to represent a wide variety of images with fine-grained features. Images of a 224 by 224 pixel resolution are compatible with the network9. Figure 4 shows the image of a thick block with five layers.

Fig. 4.

Fig. 4

DenseNet 5-layer dense block.

An output from the previous layer is used as an input to the second layer through the composite function operation. The network has L(L + 1)/2 direct connections as a result of these connections9. One advantage of DenseNet is its ability to efficiently use parameters, leading to models with fewer parameters than traditional architectures. This efficient parameter usage, combined with dense connectivity, contributes to improved accuracy and training efficiency. DenseNet has been widely adopted in the field of computer vision and has proven particularly effective in image classification tasks11.

The Particle Swarm Optimization (PSO) method was developed by Kennedy and Eberhart. It was inspired by the searching behaviors of birds. Here, the population is formed by representing each “bird” as a massless and volumeless particle. Potential solutions to the optimization problem at hand are represented by these particles. All particles are thoroughly examined in the PSO approach, taking into account both their own history and the shared experiences of nearby particles. The data is collected by PSO once the necessary characteristics have been extracted. Since there is no bulk or volume in a single person, the data is aggregated from this set of people to produce a population. Both the speed and each location are dynamically modified using these18. In order to get the most out of it, this procedure is performed several times. Consequently, they maintain a constant state of flux in their flight paths and speeds, influenced by both the local (pbest) and global (gbest) best solutions. The revised coordinates (t + 1) and speed (t + 1) of these particles are shown in the following Eqs. (3), (4), and (5):

graphic file with name d33e564.gif 3
graphic file with name d33e568.gif 4
graphic file with name d33e572.gif 5

where Oi stands for the particle’s optimal position, Gi for the particle’s global optimal position, L1 and L2 for the factors of learning, R1 and R2 for random numbers, Dmax and Dmin for the upper and lower bounds of the inertia weight, then tmax and for the maximum and current repetitions, respectively18.

As a result, several of these hyperparameters were optimized using the particle swarm optimization (PSO) technique, which removed the need for a human search to find the best hyperparameters for lung cancer classification. An evolutionary method that draws inspiration from the cooperative or swarming behavior of natural populations is the PSO algorithm. By outperforming competing optimization methods in terms of both computation time and effective stable convergence, PSO is able to provide high-quality solutions in a shorter amount of time. Additionally, it is more effective at preserving the swarm’s variety with fewer control parameters to tweak, and all the particles learn from the highest performing one (the Gbest particle) to become even better6.

Lung swarm Net

Lung Swarm Net is a mix of deep learning models that analyzes CT images to detect lung cancer. It utilizes DenseNet-201 to find features and Particle Swarm Optimization (PSO) to choose the best ones and sort them. The model’s first layer takes in lung CT pictures that have previously been processed. Then, it does an initial convolution using a 7 × 7 filter that has 64 channels and a stride of 2. This catches things like edges and textures that are low-level. A 3 × 3 max pooling layer with a stride of 2 reduces the number of spatial dimensions while maintaining critical features and speeding up the calculation. The primary section of the model is made up of DenseNet-201 blocks. Many convolution layers within each dense block pull out characteristics at higher levels. The thick connection makes sure that features may be utilized again and that the gradient flow is improved. In a concatenation layer, feature maps from various blocks are combined, which keeps information from different layers. Then, global average pooling cuts down on the number of levels to keep the model from overfitting. Fully linked layers include 256 and 64 neurons that blend characteristics in a manner that isn’t linear. A 0.5 rate dropout layer reduces overfitting even more. For binary or multi-class classification, the output layer utilizes softmax or sigmoid activation, accordingly. Lastly, PSO is utilized to make feature selection from DenseNet outputs better by focusing on the most discriminative features. In this process, PSO uses a fitness function to rank each potential combination of features. The fitness function offers higher scores to feature sets that identify lung cancer more correctly and occasionally also looks at picking fewer features to make the process more efficient. This makes sure that the model only looks at the most essential data, which makes categorization more accurate. Lung Swarm Net is a great technique for discovering lung cancer early since it can get both low- and high-level information from lung CT images.

: .

Algorithm 1.

Algorithm 1

Overall Proposed model.

Results

A The total number of images in the IQ-OTH/NCCD https://www.kaggle.com/datasets/adityamahimkar/iqothnccd-lung-cancer-dataset Lung Cancer Dataset is 84 + 36 for benign, 393 + 168 for malignant, and 291 + 125 for normal. There is a 70:30 ratio between training and testing in this dataset. The total number of images in the Chest CT-Scan https://www.kaggle.com/datasets/mohamedhanyyy/chest-ctscan-images Images Dataset is: Adenocarcinoma—237 + 101, Large Cell Carcinoma—131 + 56, Squamous Cell Carcinoma—182 + 78, and Normal—150 + 65. In addition, the data is divided into two groups: 70% and 30%. The total number of benign cases for the Lung Cancer Detection LIDC-IDRI Subset is 710 (train) + 304 (test), while the total number of malignant cases is 736 (train) + 315 (test). The dataset is also in the normal 70:30 split format.

Figure 5 shows the MATLAB GUI of the suggested lung cancer classification framework, which combines Enhanced ResNet50 for segmentation and PSO-optimized DenseNet201 (LungSwarmNet) for classification. The method starts with the input lung CT image, which is preprocessed to improve contrast and get rid of background noise. Then, it is filtered to get rid of high-frequency artifacts and highlight tumor borders. The morphological picture makes the lung area even better by getting rid of minor, unnecessary structures and clearly showing the area of interest. The Cluster1 picture illustrates the segmented result, which uses the ResNet50-based feature clustering method to precisely indicate possible tumor areas. After processing the photos, the retrieved features are sent to the PSO-optimized DenseNet201 model, which determines that the malignancy is Adenocarcinoma. This image shows how well the suggested model works to reliably segment, extract, and categorize lung cancer areas from CT scans. This proves that it is reliable for use in clinical diagnostics.

Fig. 5.

Fig. 5

Classification of Adenocarcinoma.

This Fig. 6 shows the results of classifying lung cancer using the suggested PSO-based ResNet and DenseNet architecture. The CT lung picture goes through a number of steps, such as preprocessing to improve contrast, filtering to get rid of noise, morphological procedures to improve the accuracy of the tumor location, and clustering to get the tumor location right. The PSO-optimized DenseNet classifier gets important statistical and textural information from these improved pictures. The method accurately recognizes and classifies the cancer type as Large Cell Carcinoma based on the retrieved data. This result shows how well the suggested hybrid model works to properly analyze CT scans and tell the difference between various forms of lung cancer.

Fig. 6.

Fig. 6

Classification of Large cell carcinoma.

This Fig. 7 shows the lung cancer classification results using the suggested PSO-optimized ResNet and DenseNet architecture. To identify and improve the area of interest, the lung CT image goes through many processing steps, such as filtering, morphological improvement, and segmentation. From the processed photos, important statistical and texture-based variables including mean, energy, homogeneity, and skewness are taken out. The PSO-optimized DenseNet classifier correctly recognizes and classifies the case as Squamous Cell Carcinoma using these extracted features. This result illustrates the model’s proficiency in accurately analyzing intricate CT scan patterns and providing exact lung cancer subtype categorization.

Fig. 7.

Fig. 7

Classification of Squamous cell carcinoma.

This Table 1 shows a visual overview of the main steps in the proposed PSO-optimized ResNet and DenseNet-based system for detecting lung cancer. Each row shows five important outputs for one CT scan sample: the Input Image, the Preprocessed Image, the Filtered Image, the Segmented Image, and the Classification Result. The Input Image is the original lung CT scan that was taken from the dataset. The Preprocessed Image reduces unnecessary noise and artifacts and increases contrast to make the lung anatomy stand out. The Filtered Image makes the area of interest even clearer by getting rid of high-frequency aberrations. The Enhanced ResNet50 Segmented Image, on the other hand, properly separates possible tumor areas. The Classification Result shows the kind of cancer that the PSO-optimized DenseNet201 classifier found, such as Adenocarcinoma, Squamous Cell Carcinoma, or Large Cell Carcinoma. This table clearly shows how well each processing step in the proposed model works and how well it can deliver accurate and understandable diagnostic results.

Table 1.

Outputs of different lung images.

graphic file with name 41598_2025_31000_Tab1_HTML.jpg

The percentage of cases for which the prediction was accurate relative to the total number of occurrences is called accuracy.

graphic file with name d33e703.gif 6

The accuracy of a positive prediction is defined as the percentage of true positives out of all positive predictions.

graphic file with name d33e710.gif 7

An indicator of a model’s sensitivity is its recall, which measures how well it can detect positive cases..

graphic file with name d33e716.gif 8

The F1 score, harmonizes precision and recall into a single metric, providing a balanced measure of a model’s performance7.

graphic file with name d33e726.gif 9

Figure 8 show the confusion matrix that shows how well the proposed PSO-optimized ResNet and DenseNet architecture can classify three types of lung cancer: benign, malignant, and normal. The program accurately recognized 33 cases in the Benign class (True Positives), overlooked 3 instances (False Negatives), and mistakenly categorized 10 samples as Benign (False Positives). The Malignant category had 157 predictions right, however 11 were wrong and 7 were wrongly tagged as Malignant. 116 samples were accurately identified as Normal, 9 were overlooked, and 17 were incorrectly identified as Normal in the Normal category. The findings show that the suggested system has a good capacity to classify, with high accuracy and low rates of misclassification in all three diagnostic categories. This confirms that it is reliable and resilient for automated lung cancer diagnosis.

Fig. 8.

Fig. 8

Confusion Matrix of lung cancer detection and classification with LungSwarmNet—Dataset-I.

Figure 9 present the validation metrics of LungSwarmNet for lung cancer detection and classification on Dataset-I. The model demonstrates strong performance across all classes. For benign cases, the recall is 91.67%, indicating that most true benign instances were correctly identified, though the precision of 76.74% suggests some false positives. Malignant cases achieved a high F-score of 94.58%, supported by 95.73% precision and 93.45% recall, showing excellent detection and classification capability. Normal cases exhibited balanced performance, with a precision of 87.22%, recall of 92.80%, F-score of 89.92%, and accuracy of 92.49%. Overall, these results indicate that LungSwarmNet is reliable and effective across all categories in Dataset-I.

Fig. 9.

Fig. 9

Validation parameter of lung cancer detection and classification using LungSwarmNet—Dataset-I.

Figure 10 show the confusion matrix of LungSwarmNet on Dataset-II. This shows that it can correctly identify various kinds of lung cancer and normal cases. The algorithm accurately recognized 95 instances of adenocarcinoma, missing 6 cases (false negatives) and falsely predicting 6 cases as adenocarcinoma (false positives). This shows that it is quite sensitive while yet being very precise. Large cell carcinoma had 51 true positives, 5 false negatives, and 7 false positives, which shows that the model can reliably find less prevalent kinds of cancer. Squamous cell cancer was accurately recognized, yielding 59 true positives, 6 false negatives, and just 4 false positives, indicating low misclassification. Normal cases were mostly identified properly, with 72 true positives and a high number of 208 true negatives. However, 14 cases were wrongly labeled as abnormal, showing a minor propensity to over-predict malignancy in normal data. Overall, LungSwarmNet works well and consistently across all kinds of cancer and normal instances, making it a trustworthy method for finding and classifying all forms of lung cancer.

Fig. 10.

Fig. 10

Confusion Matrix of lung cancer detection and classification with LungSwarmNet—Dataset-II.

Figure 11 exhibit the validation metrics of LungSwarmNet on Dataset-II. They indicate that it works well for a wide range of lung cancer kinds and normal cases. Adenocarcinoma had a balanced and strong performance, with precision, recall, and F-score all at 94.06%, which gave it an overall accuracy of 93.30%. The recall rate for large cell carcinoma was 91.07%, which means it was very good at finding this form of cancer. However, the somewhat lower precision rate of 87.93% means that there were some false positives. The total accuracy was 91.04%. Squamous cell carcinoma did well, with an F-score of 92.19% and a high specificity of 94.81%, which showed that it was able to tell the difference between other classes. Normal cases had a high recall rate of 92.31%, which means that most real normal cases were accurately recognized. However, the lower accuracy rate of 83.72% means that some were incorrectly classified as abnormal. In general, these findings show that LungSwarmNet works well and consistently for both malignant and normal cases in Dataset-II.

Fig. 11.

Fig. 11

Validation parameter of lung cancer detection and classification using LungSwarmNet—Dataset-II.

Figure 12 show the confusion matrix of LungSwarmNet on Dataset-III, which shows that it works well to tell the difference between benign and malignant lung cancer patients. The algorithm properly recognized 286 benign cases (True Positives), missed 18 benign cases (False Negatives), and wrongly categorized 24 benign cases as malignant (False Positives). Malignant cases were also well-classified, with 291 True Positives, 24 False Negatives, and 18 False Positives. Both groups had a lot of True Negatives (286–291), which means that the model can tell the difference between benign and cancerous samples. These findings show that LungSwarmNet is very reliable and consistent in properly finding and identifying lung cancer in Dataset-III.

Fig. 12.

Fig. 12

Confusion Matrix of lung cancer detection and classification with LungSwarmNet—Dataset-III.

Figure 13 provide the validation metrics of LungSwarmNet on Dataset-III. They show that the model is good at finding and categorizing both benign and malignant lung cancer cases. The model got a precision of 92.26% and a recall of 94.08% for benign instances, which gave it an F-score of 93.16% and an overall accuracy of 93.21%. Malignant cases had comparable performance, achieving a precision of 94.17%, a recall of 92.38%, an F-score of 93.27%, and an overall accuracy of 93.21%. These balanced measures show that LungSwarmNet can accurately tell the difference between benign and malignant samples. This shows that it works well and is strong throughout Dataset-III.

Fig. 13.

Fig. 13

Validation parameter of lung cancer detection and classification using LungSwarmNet—Dataset-III.

Using a confusion matrix, Table 2 and Fig. 14 compares LungSwarmNet to other methods on Dataset I. PSO + SVM accurately diagnosed 84 cancer cases but erroneously labeled 26 as healthy and 52 healthy cases as cancer. With 91 true positives, 19 false negatives, and 43 false positives, RESNET did better. DenseNet made things even more accurate, getting 95 true positives, 15 false negatives, and 31 false positives. LungSwarmNet found 102 cancer cases with just 8 false negatives and 11 false positives, while it accurately classified 146 healthy cases. This shows that it has better sensitivity and specificity, which means fewer missed diagnoses and overdiagnoses. The hybrid DenseNet-201 and PSO methodology in LungSwarmNet shows that it is far better at finding lung cancer than other approaches.

Table 2.

Confusion matrix comparison of LungSwarmNet to existing methodologies, Dataset I.

Algorithm True Positive False Negative False Positive True Negative
PSO + SVM21 84 26 52 105
RESNET20 91 19 43 114
Dense Net19 95 15 31 126
LungSwarmNet 102 8 11 146

Fig. 14.

Fig. 14

Confusion matrix comparison of LungSwarmNet to existing methodologies, Dataset I.

Figure 15 show how LungSwarmNet’s validation metrics compare to those of other methods on Dataset-I. LungSwarmNet beats all the other models on all the important metrics. It has the greatest precision (90.27%), recall (92.73%), F-score (91.48%), specificity (92.99%), and total accuracy (92.88%). On the other hand, PSO + SVM21 had lesser precision (61.76%) and accuracy (70.79%), ResNet20 had 67.91% precision and 76.78% accuracy, while DenseNet19 had 75.40% precision and 82.77% accuracy. The findings indicate that LungSwarmNet achieves an optimal equilibrium between accuracy and recall while reducing misclassifications, hence proving effective and dependable lung cancer detection and classification. Overall, these results show that LungSwarmNet is a big step forward from the best techniques currently available on Dataset-I.

Fig. 15.

Fig. 15

Validation comparison of LungSwarmNet to existing methodologies Dataset I.

Figure 16 show how the confusion matrix findings for LungSwarmNet compare to those of other methods on Dataset-II. LungSwarmNet shows better performance by getting the most True Positives (69) and the fewest False Negatives (6) and False Positives (8). It also has the most True Negatives (106), which shows that it is quite good at properly detecting both malignant and normal instances. PSO + SVM21 had 56 True Positives, 19 False Negatives, and 19 False Positives; ResNet20 had 58 True Positives, 17 False Negatives, and 17 False Positives; and DenseNet19 had 65 True Positives, 10 False Negatives, and 13 False Positives. These findings show that LungSwarmNet greatly lowers the number of misclassifications and is better at finding and classifying lung cancer than other methods on Dataset-II.

Fig. 16.

Fig. 16

Confusion matrix comparison of LungSwarmNet to existing methodologies, Dataset II.

Figure 16, show how LungSwarmNet compares against other methods on Dataset-II. LungSwarmNet has the most True Positives (69), the fewest False Negatives (6) and False Positives (8), and the most True Negatives (106). This in Fig. 17 shows that it is quite good at properly detecting both malignant and normal instances. LungSwarmNet also beats other models in terms of validation measures, with a precision of 89.61%, a recall of 92.00%, an F-score of 90.79%, a specificity of 92.98%, and an overall accuracy of 92.59%. PSO + SVM21 had lesser precision (74.67%) and accuracy (79.89%), ResNet20 had 77.33% precision and 82.01% accuracy, while DenseNet19 had 83.33% precision and 87.83% accuracy. These findings show that LungSwarmNet regularly lowers the number of wrong classifications and finds and classifies lung cancer more accurately and reliably than other methods on Dataset-II.

Fig. 17.

Fig. 17

Validation comparison of LungSwarmNet to existing methodologies Dataset II.

Figure 18 show how LungSwarmNet’s confusion matrix findings compare to those of other methods on Dataset-III. LungSwarmNet had the most True Positives (291) and the fewest False Negatives (24) and False Positives (18). This shows that it is better at properly classifying both benign and malignant cases. In contrast, PSO + SVM21 documented 277 True Positives with 38 False Negatives and 28 False Positives; ResNet20 reported 281 True Positives with 34 False Negatives and 26 False Positives; and DenseNet19 indicated 288 True Positives, 27 False Negatives, and 23 False Positives. These findings show that LungSwarmNet not only increases sensitivity and specificity but also lowers the number of misclassifications. This indicates that it is better than other methods for finding and classifying lung cancer on Dataset-III.

Fig. 18.

Fig. 18

Confusion matrix comparison of LungSwarmNet to existing methodologies, Dataset III.

Figure 19 provide a side-by-side comparison of the validation metrics of LungSwarmNet and other methods on Dataset-III. LungSwarmNet does better than the other models, with a precision of 94.17%, a recall of 92.38%, an F-score of 93.27%, a specificity of 94.08%, and an overall accuracy of 93.21%. PSO + SVM21 had 90.82% precision and 89.34% accuracy, ResNet20 had 91.53% precision and 90.31% accuracy, while DenseNet19 had 92.60% precision and 91.92% accuracy. LungSwarmNet’s better performance shows that it strikes a good balance between sensitivity and specificity, which reduces the number of wrong classifications and shows that it can reliably and accurately identify and classify lung cancer throughout Dataset-III.

Fig. 19.

Fig. 19

Validation comparison of LungSwarmNet to existing methodologies Dataset III.

Figure 20 show how the proposed LungSwarmNet (also known as PSO Dense Net) compares to other methods in terms of overall accuracy and mean squared error (MSE) across Datasets I, II, and III. On all three datasets, LungSwarmNet always does better than PSO + SVM21, ResNet20, and DenseNet19. It has the best accuracy for Datasets I, II, and III, at 92.88%, 92.59%, and 93.21%, respectively, and the lowest mean squared errors, at 0.1008, 0.0862, and 0.0668. PSO + SVM, on the other hand, has the lowest accuracy (70.79%, 79.89%, 89.34%) and the greatest MSE (0.1568, 0.1441, 0.1276). ResNet and DenseNet do well, but they aren’t as good as LungSwarmNet. These findings show that LungSwarmNet is more reliable, consistent, and generally better at finding and classifying lung cancer across several datasets.

Fig. 20.

Fig. 20

Accuracy and Mean squared error comparison of proposed LungSwarmNet to existing methodologies with Dataset I, II and III.

The ROC curve depicted in Fig. 21 shows how well a binary classification model works. You can see how well the model differentiates classes by displaying the True Positive Rate against the False Positive Rate. The curve goes up steeply and closely follows the top-left corner, which suggests that it is quite good at making predictions. This means that the model has a low false positive rate and a high true positive rate. The curve shows that the classifier is probably quite good, with an AUC value of around 1.0.

Fig. 21.

Fig. 21

ROC curve analysis of the proposed system.

Conclusion

This research introduced an innovative two-stage deep learning architecture for lung cancer diagnosis using CT images, including Enhanced ResNet50 for segmentation and LungSwarmNet—a PSO-optimized DenseNet201—for classification. The experimental findings show that the suggested model is better than the best current methods at finding malignant areas, proving that it works.

However, the present study has limitations, including a limited dataset size and possible susceptibility to fluctuations in CT imaging quality. Subsequent research need to concentrate on corroborating the model using bigger, multi-institutional datasets, combining multimodal imaging for more comprehensive feature extraction, and using explainable AI techniques to improve clinical interpretability. Also, hybrid transfer learning methodologies should be looked at to make the model even more accurate and faster at computing.

Author contributions

Kalaipriya Omprakash made substantial contributions to the conception or design of the work; or the acquisition, analysis, or interpretation of data; or the creation of new software used in the work. Dhandapani Samiappan drafted the work or revised it critically for important intellectual content. All authors reviewed the manuscript.

Funding

No funds, grants, or other support was received.

Data availability

The dataset used in this study is publicly available at https://www.kaggle.com/datasets/adityamahimkar/iqothnccd-lung-cancer-dataset, https://www.kaggle.com/datasets/mohamedhanyyy/chest-ctscan-images. All data supporting the findings of this research are included within the manuscript.

Declarations

Competing interests

The authors declare no competing interests.

Employment

All authors certify that they have no affiliations with or involvement in any organization or entity with any financial interest or non-financial interest in the subject matter or materials discussed in this manuscript.

Footnotes

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

References

  • 1.Šarić, M., Russo, M., Stella, M. & Sikora, M. (2019). CNN-based method for lung cancer detection in whole slide histopathology images. In 2019 4th International Conference on Smart and Sustainable Technologies (SpliTech) (pp. 1–4). IEEE.
  • 2.Pang, S., Zhang, Y., Ding, M., Wang, X. & Xie, X. A deep model for lung cancer type identification by densely connected convolutional networks and adaptive boosting. IEEE Access8, 4799–4805 (2019). [Google Scholar]
  • 3.Damayanti, N. P., Ananda, M. N. D. & Nugraha, F. W. Lung cancer classification using convolutional neural network and DenseNet. J. Soft Comput. Explor.4(3), 133–141 (2023). [Google Scholar]
  • 4.Kanakaraddi, S. G., Handur, V. S., Jalannavar, A., Chikaraddi, A. & Giraddi, S. Segmentation and classification of lung cancer using deep learning techniques. Procedia Comput. Sci.235, 3226–3235 (2024). [Google Scholar]
  • 5.Chen, W. et al. HSN: Hybrid segmentation network for small cell lung cancer segmentation. IEEE Access7, 75591–75603 (2019). [Google Scholar]
  • 6.Da Silva, G. L. F., Valente, T. L. A., Silva, A. C., De Paiva, A. C. & Gattass, M. Convolutional neural network-based PSO for lung nodule false positive reduction on CT images. Comput. Methods Programs Biomed.162, 109–118 (2018). [DOI] [PubMed] [Google Scholar]
  • 7.Sandag, G. A. & Kabo, D. T. Comparative analysis of lung cancer classification models using EfficientNet and ResNet on CT-scan lung images. CogITo Smart J.10(1), 259–270 (2024). [Google Scholar]
  • 8.Cao, H. et al. Dual-branch residual network for lung nodule segmentation. Appl. Soft Comput.86, 105934 (2020). [Google Scholar]
  • 9.Mohite, A. Application of transfer learning technique for detection and classification of lung cancer using CT images. Int. J. Sci. Res. Manag.9(11), 621–634 (2021). [Google Scholar]
  • 10.Liu, X., Li, K. W., Yang, R. & Geng, L. S. Review of deep learning based automatic segmentation for lung cancer radiotherapy. Front. Oncol.11, 717039 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Uddin, J. Attention-based DenseNet for lung cancer classification using CT scan and histopathological images. Designs8(2), 27 (2024). [Google Scholar]
  • 12.Chen, Y. et al. Classification of lungs infected COVID-19 images based on inception-ResNet. Comput. Methods Prog. Biomed.225, 107053 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Abedalla, A., Abdullah, M., Al-Ayyoub, M. & Benkhelifa, E. Chest X-ray pneumothorax segmentation using U-Net with EfficientNet and ResNet architectures. PeerJ Comput. Sci.7, e607 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.WahabSait, A. R. Lung cancer detection model using deep learning technique. Appl. Sci.13(22), 12510 (2023). [Google Scholar]
  • 15.Qayyum, A., Ang, C. K., Sridevi, S., Khan, M. A., Hong, L. W., Mazher, M. & Chung, T. D. (2020). Hybrid 3D-ResNet deep learning model for automatic segmentation of thoracic organs at risk in CT images. In 2020 International Conference on Industrial Engineering, Applications and Manufacturing (ICIEAM) (pp. 1–5). IEEE.
  • 16.Arthi, T., Premkumar, S., Sivakumar, S. & Partheeban, N. (2023). Leveraging DenseNet and Genetic Algorithms for Lung Cancer Severity Classification. In 2023 1st International Conference on Optimization Techniques for Learning (ICOTL) (pp. 1–6). IEEE.
  • 17.Mienye, I. D., Sun, Y. & Wang, Z. Improved predictive sparse decomposition method with densenet for prediction of lung cancer. Int. J. Comput.1, 533–541 (2020). [Google Scholar]
  • 18.Raghuvanshi, S. S., Arya, K. V. & Patel, V. PSbBO-Net: A hybrid particle swarm and bayesian optimization-based DenseNet for lung cancer detection using histopathological and CT images. Int. J. Electr. Electron. Res.12(3), 1074–1086 (2024). [Google Scholar]
  • 19.Kalaivani, N., Manimaran, N., Sophia, S. & Devi, D. D. (2020). Deep learning based lung cancer detection and classification. In IOP conference series: materials science and engineering (Vol. 994, No. 1, p. 012026). IOP Publishing.
  • 20.Biyyala, V. (2023). Lung image segmentation: Custom U-Net with ResNet encoder architecture.
  • 21.Asuntha, A., Singh, N. & Srinivasan, A. PSO, genetic optimization and SVM algorithm used for lung cancer detection. J. Chem. Pharm. Res.8(6), 351–359 (2016). [Google Scholar]
  • 22.Lyu, J., Bi, X. & Ling, S. H. Multi-level cross residual network for lung nodule classification. Sensors20(10), 2837 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Jalali, Y., Fateh, M., Rezvani, M., Abolghasemi, V. & Anisi, M. H. ResBCDU-Net: A deep learning framework for lung CT image segmentation. Sensors21(1), 268 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Xiao, Z., Liu, B., Geng, L., Zhang, F. & Liu, Y. Segmentation of lung nodules using improved 3D-UNet neural network. Symmetry12(11), 1787 (2020). [Google Scholar]
  • 25.Zhang, F., Wang, Q. & Li, H. Automatic segmentation of the gross target volume in non-small cell lung cancer using a modified version of ResNet. Technol. Cancer Res. Treat.19, 1533033820947484 (2020). [Google Scholar]
  • 26.Chavan, M., Varadarajan, V., Gite, S. & Kotecha, K. Deep neural network for lung image segmentation on chest x-ray. Technologies10(5), 105 (2022). [Google Scholar]
  • 27.Zhang, G., Lin, L. & Wang, J. (2021). Lung nodule classification in CT images using 3D DenseNet. In Journal of Physics: Conference Series (Vol. 1827, No. 1, p. 012155). IOP Publishing.

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The dataset used in this study is publicly available at https://www.kaggle.com/datasets/adityamahimkar/iqothnccd-lung-cancer-dataset, https://www.kaggle.com/datasets/mohamedhanyyy/chest-ctscan-images. All data supporting the findings of this research are included within the manuscript.


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES