Pulmonary edema is a lung disorder characterized by fluid accumulation in the alveolar and interstitial spaces, which disrupts gas exchange and reduces oxygen levels in the blood. Chest X-ray (CXR) imaging is commonly used for pulmonary edema assessment because it is fast and widely available; however, its interpretation still depends heavily on radiologist expertise and may lead to diagnostic variability, particularly in healthcare facilities with limited radiology resources. This study aims to develop an automated pulmonary edema detection system based on deep learning to support more consistent analysis of CXR images. The novelty of this study lies in the integration of Grey Wolf Optimizer (GWO) for hyperparameter optimization of the YOLOv5n model specifically for pulmonary edema detection in Chest X-ray images. The proposed method employs YOLOv5n as a lightweight object detection architecture because of its computational efficiency and suitability for resource-constrained environments. To improve detection performance and training stability, the hyperparameters of YOLOv5n are optimized using GWO. The model is trained and evaluated using annotated CXR images, and its performance is measured using precision, recall, mAP@0.5, and mAP@0.5–0.95. Experimental results show that the YOLOv5n + GWO model achieved a precision of 0.906, recall of 0.936, mAP@0.5 of 0.963, and mAP@0.5–0.95 of 0.737, indicating improved detection performance compared with the baseline YOLOv5n configuration. The proposed framework demonstrates potential as a decision-support tool for assisting medical personnel in early pulmonary edema screening through efficient and consistent analysis of CXR images.