Lung cancer is an increasingly serious health problem worldwide, and early detection and diagnosis are crucial for successful treatment. With the development of artificial intelligence and the growth of data volume, machine learning techniques can play a significant role in improving the accuracy of early detection in lung cancer.This study proposes a deep learning-based segmentation algorithm for rapid on-site cytopathological evaluation (ROSE) to enhance the diagnostic efficiency of endobronchial ultrasoundguided transbronchial needle aspiration biopsy (EBUS-TBNA) during surgery. By utilizing the CUNet3+ network model, cell clusters, including cancer cell clusters, can be accurately segmented in ROSE-stained pathological sections. The model demonstrated high accuracy, with an F1-score of 0.9604, recall of 0.9609, precision of 0.9654, and accuracy of 0.9834 on the internal testing dataset. It also achieved an AUC of 0.9972 for cancer identification. The proposed algorithm provides time savings for on-site diagnosis, improves EBUS-TBNA efficiency, and outperforms classical segmentation algorithms in accurately identifying lung cancer cell clusters in ROSE-stained images. It effectively reduces over-segmentation, decreases network parameters, and enhances computational efficiency, making it suitable for real-time patient evaluation during surgical procedures.