This repository contains code and resources that were utilized in the following paper:
Lung Cancer Identification from CT Scans using a Soft-attention enabled Deep Transfer Learning Model
S. Dev, P. S. Roy, N. Chakraborty and R. Sarkar
Published in: IEEE ISACC 2025
Paper: https://doi.org/10.1109/ISACC65211.2025.10969319
If you use this code or find it helpful, please consider citing the paper.
@inproceedings{10969319,
author = {S. Dev, P. S. Roy, N. Chakraborty and R. Sarkar},
title = {Lung Cancer Identification from CT Scans using a Soft-attention enabled Deep Transfer Learning Model},
booktitle = {2025 3rd International Conference on Intelligent Systems, Advanced Computing and Communication (ISACC)},
pages = {254-259},
year = {2025},
doi = {10.1109/ISACC65211.2025.10969319}
}You can download the paper here as well IEEE ISACC 2025 10969319
Sample images from datasets, diagnosed as either lung cancer or healthy.
In this research, three popular datasets which are publicly available, are considered for training and evaluating the proposed system. These datasets are relatively small and provide the necessary challenges that tend to pose limitations of the DL models. The details of the considered datasets are provided in the following sub-sections:
The dataset comprises CT scans of patients at various stages of lung cancer and healthy subjects, marked by oncologists and radiologists. The dataset consists of 1190 CT scan images from 110 cases, categorized into three classes: normal (55 cases), benign (15 cases), and malignant (40 cases). Table 1 shows the organization of the IQ-OTH/NCCD dataset.
This dataset consists of 25,000 histopathological images, divided into five distinct classes. We consider only three classes namely, Lung Benign tissue, Lung Adenocarcinoma and Lung Squamous cell carcinoma. As depicted in Table 2, each class contains ≈ 5000 images divided into 80% training set while validation and test sets having 10% images each. All images are 768×768 pixels in size and are in jpeg file format. The dataset contains histopathological images of lung and colon tissues. Since our work is centered around lung cancer, we would only be considering the lung image set comprising 15000 images.
This dataset consists of diagnostic and lung cancer screening thoracic CT scans with marked-up annotated lesions. It is a web-accessible international resource for development, training, and evaluation of CAD methods for lung cancer detection and diagnosis.The dataset consists of 2066 images distributed across a train set of 1323 images, a test set of 413 images and a validation set of 330 images. Each set further has data distributed across 3 subclasses viz., benign and malignant. This dataset comprises diagnostic and lung cancer screening thoracic CT scans with annotated lesions.
Here, two base models called MobileNetV2 and DenseNet121 are explored for understanding the efficiency in lung cancer identification. In both the cases, an input image of size 224×224×3 from the lung cancer image dataset
In MobileNetV2, there are two types of blocks. As shown in Fig. 3, one is residual block with stride of and Another one is block with stride of 2 for downsizing. There are 3 layers for both types of blocks. This time, the first layer is 1×1 convolution with ReLU6. The second layer is the depthwise convolution. The third layer is another 1×1 convolution but without any non-linearity. It is claimed that if ReLU is used again, the deep networks only have the power of a linear classifier on the non-zero volume part of the output domain. And there is an expansion factor t. And t=6 for all main experiments. If the input got 64 channels, the internal output would get 64×t=64×6=384 channels where t: expansion factor, c: number of output channels, n: repeating number, s: stride. 3×3 kernels are used for spatial convolution. In typical use, the primary network (width multiplier 1, 224×224), has a computational cost of 300 million multiply-adds and uses 3.4 million parameters. The performance tradeoffs are further explored, for input resolutions from 96 to 224, and width multipliers of 0.35 to 1.4. The network computational cost up to 585M MAdds, while the model size varies between 1.7M and 6.9M parameters. To train the network, 16 GPUs are used with a batch size of 96.
In DenseNet121, there are two types of layers: convolutional layers within dense blocks and transition layers for down-sampling as depicted in Fig. 4. Each dense block consists of multiple layers where each layer receives input from all preceding layers. There are 3 key operations in each dense block layer. The first is a 1×1 convolution followed by ReLU. The second is a 3×3 convolution, and the third operation is concatenation of the input with its preceding layers’ outputs, promoting feature reuse. There is a growth rate k that determines the number of output channels per layer. For all main experiments, k is typically set to 32. If the input has 64 channels, after one layer, the output would have 64 + k = 64 + 32 = 96 channels. Transition layers, which include a 1×1 convolution followed by 2×2 average pooling, are used for down-sampling between dense blocks. These layers help control the complexity of the network and manage the size of the feature maps.

As the primary aim of our experiment was to develop a lightweight model we have implemented a soft attention [28] in our model. Soft attention is an attention mechanism where the model calculates a weighted sum of all the elements in the input image. The "soft" aspect refers to the fact that the attention distribution is continuous and differentiable, meaning the model can focus on multiple parts of the input to varying degrees rather than selecting just one part. Here the soft attention unit accepts a feature tensor T of size rcd generated by the output Om from Eqn. (1) and applies convolution on T by employing a 3D kernel of size 3×3×d which produces a feature map Fatt of size rc×1. Thus for n such kernels, feature maps of size rcn get generated. These feature maps undergo normalization using the softmax function and merging to determine a soft attention score
given by
The final weighted feature outcome is given by
in Eqn. (3) where the features in Fatt is multiplied with
to enhance the significance of the relevant feature values. This product is re-scaled by a learning weight . Finally, the re-scaled weighted features are added with the original feature of
to aid in performing optimal selection of feature map regions that are more relevant in the identification of a lung cancer class.
All the experimentation has been performed on Kaggle Notebook editor. We have utilized Kaggle’s GPU T4-X2 as an accelerator. Additionally for all the datasets we have ensured the same hyperparameters values as listed in Table 4. We preprocess lung cancer images from each dataset.
Test Loss: 0.03285326808691025
Test Accuracy: 0.9954545497894287
Test Loss: 0.06389608979225159
Test Accuracy: 0.9863636493682861
Test Loss: 0.2601519525051117
Test Accuracy: 0.9673333168029785
Test Loss: 0.1851891279220581
Test Accuracy: 0.968666672706604
Test Loss: 0.11375235766172409
Test Accuracy: 0.9491525292396545
Test Loss: 0.28500422835350037
Test Accuracy: 0.9200968742370605
































