Non-small cell lung cancer (NSCLC) is one of the leading causes of cancer mortality worldwide. Immune checkpoint inhibitors (ICIs) have emerged as a crucial treatment option for patients with advanced NSCLC. However, only a subset of patients experience clinical benefit from ICIs. Therefore, identifying biomarkers that can predict response to ICIs is imperative for optimising patient selection. Hematoxylin and eosin (H&E) images of NSCLC patients were obtained from the local cohort (n = 106) and The Cancer Genome Atlas (TCGA) (n = 899). We developed an ICI-related pathological prognostic signature (ir-PPS) based on H&E stained histopathology images to predict prognosis in NSCLC patients treated with ICIs using deep learning. To accomplish this, we employed a modified ResNet model (ResNet18-PG), a widely-used deep learning architecture well-known for its effectiveness in handling complex image recognition tasks. Our modifications include a progressive growing strategy to improve the stability of model training and the use of the AdamW optimiser, which enhances the optimisation process by adjusting the learning rate based on training dynamics. The deep learning model, ResNet18-PG, achieved an area under the receiver operating characteristic curve (AUC) of 0.918 and a recall of 0.995 on the local cohort. The ir-PPS effectively risk-stratified NSCLC patients. Patients in the low-risk group (n = 40) had significantly improved progression-free survival (PFS) after ICI treatment compared to those in the high-risk group (n = 66, log-rank P = 0.004, hazard ratio (HR) = 3.65, 95%CI: 1.75-7.60). The ir-PPS demonstrated good discriminatory power for predicting 6-month PFS (AUC = 0.750), 12-month PFS (AUC = 0.677), and 18-month PFS (AUC = 0.662). The low-risk group exhibited increased expression of immune checkpoint molecules, cytotoxicity-related genes, an elevated abundance of tumour-infiltrating lymphocytes, and enhanced activity in immune stimulatory pathways. The ir-PPS signature derived from H&E images using deep learning could predict ICIs prognosis in NSCLC patients. The ir-PPS provides a novel imaging biomarker that may help select optimal candidates for ICIs therapy in NSCLC.