The study focused on how to improve the diagnostic coincidence rate of patients with gallbladder stones and gallbladder cancer based on an optimized Segnet network algorithm and the relationship of gallbladder cancer with multiple tumor suppressor 1 (P16). 300 patients diagnosed with gallbladder cancer in the hospital were selected as the research subjects. The pyramid pooling operation was incorporated into the original Segnet network algorithm, and its performance was evaluated, factoring into the intersection of union (IoU), algorithm precision (Pre), and recall rate (Recall). After 8 hours of fasting, conventional ultrasound and contrast-enhanced ultrasound examinations were performed, and the images were evaluated by three experienced ultrasound diagnosticians. The positive signal of P16 immunohistochemical staining was brownish yellow, which was generally concentrated in the nucleus, and a small part was located in the cytoplasm. In each slice, ten visual fields were selected. Then, they were observed under a high-power mirror, and the number was counted. It was found that the optimized Segnet network algorithm increased the IoU by 7.3%, the precision by 8.2%, and the recall rate by 11.1%. The diagnostic coincidence rates of conventional ultrasound and contrast-enhanced ultrasound examinations for gallbladder cancer were 78.13% (25/32) and 87.5% (25/32), respectively. The positive expression rate of P16 in gallbladder adenocarcinoma (47.06%) was significantly lower than that of acute cholecystitis with gallbladder stones (84.38%) and gallbladder polyps (67.16%) (
P
<
0.05
). The positive expression rate of P16 in patients with stage III and stage IV (33.33% and 40%) was significantly lower than that in patients with stages I and II (87.5% and 80%) (
P
<
0.05
). The positive expression rate of P16 in high differentiation (86.67%) was significantly higher than that of moderate differentiation (40%) and poor differentiation (28.57%) (
P
<
0.05
). In short, contrast-enhanced ultrasound can effectively improve the diagnostic coincidence rate of gallbladder cancer, and the expression of P16 in gallbladder cancer is closely related to tumor staging and differentiation.