IntroductionImmune infiltration within the tumor microenvironment (TME) plays a significant role in the onset and progression of hepatocellular carcinoma (HCC). Machine learning applied to pathological images offers a practical means to explore the TME at the cellular level. Our former research employed a transfer learning procedure to adapt a convolutional neural network (CNN) model for cell recognition, which could recognize tumor cells, lymphocytes, and stromal cells autonomously and accurately within the images. This study introduces a novel immune classification system based on the modified CNN model.MethodPatients with HCC from both Beijing Hospital and The Cancer Genome Atlas (TCGA) database were included in this study. Additionally, least absolute shrinkage and selection operator (LASSO) analyses, along with logistic regression, were utilized to develop a prognostic model. We proposed an immune classification based on the percentage of lymphocytes, with a threshold set at the median lymphocyte percentage.ResultPatients were categorized into high or low infiltration subtypes based on whether their lymphocyte percentages were above or below the median, respectively. Patients with different immune infiltration subtypes exhibited varying clinical features and distinct TME characteristics. The low-infiltration subtype showed a higher incidence of hypertension and fatty liver, more advanced tumor stages, downregulated immune-related genes, and higher infiltration of immunosuppressive cells. A reliable prognostic model for predicting early recurrence of HCC based on clinical features and immune classification was established. The area under the curve (AUC) of the receiver operating characteristic (ROC) curves was 0.918 and 0.814 for the training and test sets, respectively.DiscussionIn conclusion, we proposed a novel immune classification system based on cell information extracted from pathological slices, provides a novel tool for prognostic evaluation in HCC.