Why automated histopathology classification matters. Lung cancer is the leading cause of cancer-related mortality worldwide, and accurate histological subtyping is essential because adenocarcinoma, squamous cell carcinoma, and small cell carcinoma each require fundamentally different treatment approaches. Manual pathological analysis by trained specialists is time-consuming, subjective, and increasingly strained by growing caseloads.
CNNs as the dominant approach. Convolutional Neural Networks have achieved remarkable performance in histopathology image classification, learning hierarchical feature representations from raw pixel data without manual feature engineering. Large architectures including ResNet, DenseNet, and EfficientNet have demonstrated over 98% accuracy on benchmark datasets such as LC25000, but their computational demands make them impractical for resource-constrained clinical environments.
The computational bottleneck of large models. Large CNNs face four deployment barriers in clinical settings: high GPU memory requirements, long inference latency, overfitting on small medical datasets due to parameter excess, and regulatory concerns about interpretability. These barriers collectively prevent state-of-the-art research models from being integrated into routine diagnostic workflows outside specialized academic centers.
The lightweight CNN opportunity. Lightweight CNN architectures such as MobileNet, EfficientNet-B0, and custom compact designs offer a viable path forward, achieving competitive classification accuracy with dramatically fewer parameters, faster inference, and smaller memory footprints. This study designs, implements, and comparatively evaluates four custom lightweight CNN variants specifically optimized for lung cancer histopathology classification.
A controlled comparative study. Four lightweight CNN variants -- Lite-V0, Lite-V1, Lite-V2, and Lite-V4 -- were designed to differ only in depth and filter width, while sharing an identical training pipeline, data preprocessing, augmentation, optimizer, and evaluation protocol. This controlled design isolates the effect of architectural capacity from all other confounding factors.
Three design motivations. The study addresses three specific gaps in prior work: the need for simpler and faster models suitable for resource-limited clinical environments; the lack of systematic comparisons among multiple lightweight models under standardized conditions; and the importance of optimizing macro-F1 rather than raw accuracy to ensure balanced performance across all cancer subtypes including clinically critical minority classes.
Macro-F1 as the primary metric. Accuracy can be misleading when class distributions are uneven, masking poor performance on less frequent but clinically significant subtypes. Macro-averaged F1 computes the harmonic mean of precision and recall for each class independently and then averages across classes equally, ensuring that all subtypes contribute equally to the performance estimate regardless of sample frequency.
Reproducibility by design. The study implemented a fully reproducible experimental framework: fixed random seeds at the OS, Python, NumPy, and TensorFlow levels; stratified train/validation/test splits with no overlap; automatic JSON logging of all hyperparameters and best metric values; and PNG exports of training curves and confusion matrices. Code was made publicly available to facilitate independent verification.
Balanced histopathology dataset. The study used a lung histopathology dataset with three tissue classes: benign lung tissue, lung adenocarcinoma, and lung squamous cell carcinoma. The dataset was partitioned into 10,500 training images (3,500 per class), 1,500 validation images (500 per class), and 3,000 test images (1,000 per class), with strict class balance and no overlap between splits.
Standardized preprocessing pipeline. All images were resized to 224 by 224 pixels using bilinear interpolation. Pixel intensities were normalized to the 0 to 1 range by dividing by 255. Data augmentation applied only to the training set included random horizontal flips, small random rotations of up to 5 degrees, and random zooms of up to 5 percent. Validation and test images were evaluated unaugmented to ensure consistent performance measurement. The entire pipeline was implemented using the TensorFlow tf.data API with automatic prefetching.
Shared architectural pipeline across all variants. All four variants implement the same canonical processing flow: convolutional filtering with 3x3 kernels, followed by batch normalization, ReLU activation, and max pooling for spatial downsampling. After the convolutional stack, global average pooling collapses spatial dimensions into a fixed-length embedding, which passes through a 256-unit fully connected layer, a dropout layer with rate 0.4, and a final softmax classifier producing probabilities for each of the three lung tissue classes.
Four variants differing only in depth and width. Lite-V0 is the minimal baseline with approximately 0.35 million parameters and a filter progression of 16 to 32 to 64. Lite-V1 increases depth to four convolutional blocks with 0.75 million parameters. Lite-V2, designed as the balanced sweet spot, uses five convolutional blocks with a 32 to 64 to 128 to 256 to 256 filter progression and approximately 1.2 million parameters. Lite-V4, the deepest variant, adds a sixth block reaching 2.1 million parameters, testing whether further depth yields diminishing returns or introduces overfitting.
Consistent training configuration. All variants were trained with the Adam optimizer at a learning rate of 1 times 10 to the negative 3, sparse categorical cross-entropy loss, and a batch size of 32 for up to 25 epochs. Training was executed on an NVIDIA Tesla T4 GPU in Google Colab. A fixed random seed of 42 was applied at all levels of the software stack to ensure deterministic reproducibility across runs.
Custom F1-based early stopping callback. A custom Keras callback computed validation macro-F1 at the end of each epoch. Whenever macro-F1 improved beyond a tolerance of 0.0001, the callback saved the corresponding model checkpoint and reset the patience counter. If macro-F1 failed to improve for six consecutive epochs, training was terminated automatically. This approach prevents overfitting while ensuring the saved model maximizes balanced multi-class performance rather than aggregate accuracy.
Class weighting for imbalance robustness. Although the training set was perfectly class-balanced, class weights were computed using scikit-learn's balanced weighting scheme and incorporated into the loss function. This maintains a consistent pipeline that can generalize to real-world scenarios where class imbalance is common and where the cost of misclassifying rare but clinically important subtypes is disproportionately high.
Comprehensive experiment logging. Each training run automatically produced: the best model checkpoint by validation macro-F1; a JSON run record with all hyperparameters, random seed, and peak metrics; PNG exports of accuracy, loss, and macro-F1 training curves; and confusion matrices for both validation and test sets. TensorBoard logs enabled interactive per-run inspection. This logging infrastructure ensures every result is traceable and independently reproducible.
Lite-V2 selected as the best model. Among all four variants, Lite-V2 achieved the highest validation macro-F1 score of 0.9596 and was therefore selected for final evaluation on the held-out test set. Model selection was based exclusively on validation macro-F1, with no test set information used during architecture selection or hyperparameter tuning.
Strong test set generalization. The selected Lite-V2 model achieved a test macro-F1 score of 0.9639, confirming that its strong validation performance generalized to unseen data. This result demonstrates that the five-block, 1.2 million parameter architecture represents an effective sweet spot between representational capacity and overfitting risk for this three-class histopathology classification task.
Overfitting increases with depth. Training curve analysis showed that shallower variants (Lite-V0 and Lite-V1) reached peak validation performance earlier but plateaued due to limited representational capacity. The deepest variant Lite-V4, despite continuing to improve on training accuracy, showed a widening gap between training and validation accuracy in later epochs, signaling overfitting consistent with its 2.1 million parameter capacity relative to the dataset size.
Macro-F1 reveals what accuracy cannot. Because all three classes were equally balanced in the dataset, accuracy and macro-F1 were closely aligned in this experiment. However, the use of macro-F1 as the primary selection and stopping criterion ensures that Lite-V2's strong performance reflects genuine per-class balance rather than dominance by any single tissue class, which is critical for clinical deployment where all three histological categories must be reliably distinguished.
Competitive performance with minimal parameters. Lite-V2's test macro-F1 of 0.9639 with only 1.2 million parameters compares favorably to prior lightweight CNN studies in lung histopathology. Domain-specific compact architectures such as ReducedFireNet and MobiHisNet have reported mean accuracies around 96 to 97 percent with very small model sizes, and the present Lite-V2 achieves performance in the same range while being directly benchmarked against three other variants under controlled conditions.
The gap between benchmark and real-world deployment. While large pretrained models achieve over 98% accuracy on standard benchmark datasets, this performance depends on GPU acceleration, high memory resources, and sometimes cloud connectivity -- none of which are guaranteed in clinical pathology laboratories or low-resource hospitals. Lightweight CNNs like Lite-V2 enable local on-device inference, preserving patient data privacy and regulatory compliance with frameworks such as HIPAA and GDPR, while avoiding cloud dependency.
Foundation models versus lightweight architectures. Foundation models pretrained on massive histopathology datasets such as BEPH have shown impressive generalization but require extensive GPU resources for fine-tuning. Lightweight architectures remain attractive for localized clinical deployment due to their interpretability and reduced resource requirements. Bridging these paradigms, by leveraging insights from foundation models to initialize lightweight networks, represents a promising future direction.
The importance of reproducible comparative studies. A core contribution of this work is methodological: by evaluating multiple architectures under identical preprocessing, augmentation, optimizer, and evaluation conditions, the study isolates architectural capacity as the sole variable. Prior work predominantly proposes single novel variants evaluated against heterogeneous baselines, making fair cross-study comparison difficult. Standardized comparative pipelines are increasingly recommended as the field matures.
A validated framework for lightweight clinical pathology AI. This study establishes a reproducible benchmark for lightweight CNN development in lung histopathology, demonstrating that a carefully designed compact architecture can achieve near state-of-the-art classification performance across three clinically meaningful tissue classes. The Lite-V2 variant, with 1.2 million parameters and test macro-F1 of 0.9639, represents a practical solution for integration into clinical diagnostic workflows.
Deployment advantages beyond accuracy. The proposed framework's clinical value extends beyond raw classification performance. Lower parameter count reduces memory footprint and enables deployment on hospital servers or embedded systems without GPU requirements. Local inference eliminates cloud dependency and patient data privacy concerns. The modular codebase and comprehensive logging facilitate regulatory audits and model validation processes required for clinical certification.
Extending to larger and more diverse datasets. A key limitation of this study is that the histopathology dataset used, while well-structured and balanced, may not capture the full spectrum of staining variation, scanner heterogeneity, and morphological diversity present across clinical institutions. Multi-center external validation using datasets from different laboratories, staining protocols, and whole slide imaging systems is needed to confirm that performance generalizes to real-world diagnostic practice.
Future research directions. The authors identify three priority areas for follow-up: first, training Lite-V2 on larger and more diverse multi-institutional histopathology datasets including LungHist700 and multi-center collections; second, incorporating explainability mechanisms such as Grad-CAM or attention visualization to show pathologists which tissue regions drive classification decisions; and third, exploring whether insights from foundation models can be distilled into lightweight architectures, combining the representational power of large pretrained networks with the deployment efficiency of compact designs.