Pneumonia, a respiratory infection caused by microbes, is a major health concern, particularly in underdeveloped areas. Factors like high pollution, poor sanitation, crowded housing, and insufficient health care add to its frequency. Pneumonia often progresses to pleural effusion, where fluid fills the lungs, hindering breathing. Timely and precise pneumonia diagnosis is vital for proper treatment and better survival. Chest X-ray is the primary diagnostic method, though analysis can be difficult and variable. This work aims to enhance pneumonia detection accuracy from chest X-rays using various techniques. Key challenges include subjectivity in interpretation and developing robust algorithms for automated detection. Optimizing diagnosis could improve clinical workflows and patient outcomes. The analysis encompasses three main areas: data preprocessing, model experimentation, and performance enhancement through hyperparameter tuning and ensembling. In the data preprocessing phase, various techniques like transforming data to grayscale, applying random rotations, normalizing pixel intensity values, resizing images, and weighted random sampling were employed to enhance model generalization. The model experimentation involved assessing ResNet-9, custom CNN, and ResNet-18 architectures. The ResNet-18 architecture proved to be the most effective for pneumonia classification due to its balance between complexity and generalization. Hyperparameter tuning using Optuna further optimized the model performance, resulting in improved accuracy compared to default parameter settings. We also utilized an ensemble approach, using K-fold cross-validation, resulting in a 3% increase in accuracy compared to using a single model. In this work, we implemented and analyzed a comprehensive methodology combining effective data preprocessing, model architecture exploration, hyperparameter tuning, and ensemble techniques to highlight ways that can be implemented to enhance pneumonia detection accuracy for chest X-ray images. Our proposed methodology can be extended to other domains of image classification problems using deep learning models.