This repository contains a full pipeline to reproduce, test, and critique the methodology proposed in the IEEE paper: "A Novel Hybrid CNN-Quantum Neural Network Framework with Quantum Acceleration and Error Correction for High-Precision Breast Cancer Classification on AI Edge Devices."
While the repository successfully implements the mathematical architecture described by the authors using PyTorch and PennyLane, our replication study uncovered severe inconsistencies and impossible claims in the original publication.
The original paper vaguely references "Open-source RSNA databases." To make this reproduction scientifically rigorous, this repository uses the CBIS-DDSM (Curated Breast Imaging Subset of DDSM) dataset (specifically the Mass Training and Test Sets).
Because full breast mammograms contain massive amounts of empty space, our pipeline specifically isolates and extracts the cropped Regions of Interest (ROIs) containing the actual tissue abnormalities.
- Classes: Benign (1) vs. Malignant (0).
- Format: DICOM paths mapped to high-resolution JPEGs.
Note on Data Access: To run this repository, you must download the CBIS-DDSM dataset from Kaggle. Extract the downloaded folder and place the
jpeg/andcsv/directories inside an./archive/folder in the root of this project.
Below are examples of the isolated tissue crops the network uses to classify the tumors.
| Benign Tumor (Class 1) | Malignant Tumor (Class 0) |
|---|---|
![]() |
![]() |
| Smooth, well-defined edges. | Irregular, spiked, or lobulated edges. |
The pipeline is entirely modular and designed to be run sequentially from data extraction to final quantum evaluation.
db_preprocess.py&db_preprocess_test.py: Reads the messy Kaggle CSVs, filters out irrelevant full-breast scans, calculates pixel densities to find the cropped ROIs, and generates clean CSVs for both the train and test splits.dataset_gen.py: Physically copies the targeted.jpgfiles and organizes them into a strict PyTorchImageFolderdirectory structure (./cbis_ddsm/train/...and./cbis_ddsm/test/...).data_verify.py: A visual sanity check that loads the cleaned dataset and plots the cropped breast cancer images in a grid to ensure labels align before training.
resnet152.py(Classical Baseline): Implements standard Transfer Learning. Loads a pre-trained ResNet152, swaps the final classifier head, and trains it on the medical dataset. Savesclassical_resnet_weights_best.pth.qnn.py(Hybrid Quantum Network): Implements Quantum Transfer Learning. Freezes the ResNet152 backbone, strips the final linear layer, and pipes the 2048-dimensional features into a PennyLane Dressed Quantum Neural Network (8-qubits, 6 entangling layers). Saveshybrid_qnn_weights_best.pth.
perf_comparision.py: Parses the training logs (train_log.csvandqnn_train_log.csv) and plots side-by-side comparisons of the optimization curves.classical_inference.py&qnn_inference.py: Standalone testing scripts that load the trained weights, disable gradient calculation, and evaluate the models against the completely unseen holdout test set (generating Accuracy, Loss, Precision/Recall, and Confusion Matrices).
| Model Architecture | Starting Val Accuracy | Peak Val Accuracy |
|---|---|---|
| Classical ResNet152 | 50.37% | 76.51% |
| Hybrid QNN | 73.48% | 75.38% |
- Accelerated Convergence: The Hybrid QNN effectively leverages the pre-trained classical ResNet backbone as a powerful deterministic feature extractor. Because the quantum circuit is fed highly refined spatial features, the hybrid model starts with an exceptionally strong baseline (73.48% validation accuracy at Epoch 0) and reaches its global minimum almost instantly.
- Training Efficiency: While the classical ResNet requires extensive epoch cycles to slowly optimize its final classification layers, the Hybrid QNN reaches peak performance in a fraction of the optimization steps. This proves a highly compressed 8-qubit quantum layer can match the representational power of a massive classical classifier head.
To test the true generalization of both models, we evaluated them on a strictly isolated holdout test set consisting of 378 entirely unseen images (147 Malignant, 231 Benign).
While the classical model achieved a slightly higher raw accuracy (71.69% vs 69.31%), an analysis of the Confusion Matrices reveals an interesting observation in the QNN's decision boundary regarding Recall (Sensitivity).
- Classical Malignant Recall: Successfully caught 67% of actual cancers.
- Quantum Malignant Recall: Successfully caught 73% of actual cancers.
In medical machine learning, missing a malignant tumor (False Negative) is vastly more dangerous than a False Positive. The Hybrid QNN naturally sacrificed a small amount of precision to become significantly more sensitive to the minority class (Malignant features).
Conclusion: Squeezing a 2048-dimensional vector into an 8-qubit variational circuit did not yield 97% accuracies. However, the quantum state space naturally aligned to be far more sensitive to critical cancer features. In a medical context where False Negatives are fatal, this quantum sensitivity shift encourages further investigation.
-
Clone the repository and install dependencies:
pip install torch torchvision pandas pennylane matplotlib scikit-learn seaborn
-
Run the pipeline sequentially:
# 1. Prep the Data
python db_preprocess.py
python db_preprocess_test.py
python dataset_gen.py
python data_verify.py
# 2. Train the Models
python resnet152.py
python qnn.py
# 3. Evaluate & Generate Graphs
python perf_comparision.py
python classical_inference.py
python qnn_inference.py(Note: You can answer y to the prompt in the scripts to run a fast 20-image test mode before committing to the full dataset).




