In the context of diagnosing lung disorders like bacterial and viral pneumonia and COVID-19, the challenge of sample scarcity often results in imbalanced datasets, making reliable forecasting difficult. To address this, an Optimized Wasserstein Deep Convolutional Generative Adversarial Network Technique was proposed for the Classification of COVID-19 and Pneumonia (CCP WDCGAN-SOA). The proposed approach utilizes CT scan and Xray images from two datasets: the COVID-19 Posterior-Anterior Chest Radiography Images Curated Dataset and the COVID QU-Ex Dataset. Due to the imbalance in these datasets, a Label Correlation Guided Borderline Oversampling (LCGBO) method was introduced to balance the classes effectively. Following data balancing, the images undergo pre-processing using Multimodal Hierarchical Graph Collaborative Filtering (MHGCF) for resizing. Subsequently, the processed images are fed into a Wasserstein Deep Convolutional Generative Adversarial Network (WDCGAN) optimized with the Seasons Optimization Algorithm (SOA) to enhance classification accuracy for COVID-19 and pneumonia. The implementation in MATLAB demonstrates that the CCP-WDCGANSOA technique significantly outperforms existing methods. Specifically, the proposed approach achieves improvements of 21.5 %, 23 %, and 22.5 % in accuracy, 12.3 %, 17.5 %, and 14 % in recall, and 22.3 %, 27.5 %, and 24 % in specificity compared to DC-CXI-CoviXNet, CPD-CXI-CNN, and ADC-CXI-DFFC Net using the COVID19 Posterior-Anterior Chest Radiography Images Curated Dataset. Additionally, the proposed method shows gains of 21.52%, 27.05%, and 23.24% in accuracy, 23.71%, 26.45%, and 21.74% in recall, and 28.61%, 22.15%, and 26.44% in specificity over ASC-CXI-LRANet, RCP-MIA-CNN, and AQCD-CR-GAN using the COVID-QU-Ex Dataset.