The study presents a new method for gastric cancer detection using artificial intelligence, which combines two powerful neural networks (DenseNet-121 and ResNet-50) to drive the lighter MobileNet-V2 model. This method achieves high accuracy - the MobileNet-V2 student network achieved an accuracy of 95.78% to 98.33% depending on the resolution of the analyzed samples. The main advantage is that the student model is more than thirty times smaller and almost twice as fast as the teacher models, making it suitable for real-time use on resource-constrained devices. The study also uses an integrated gradients technique that explains which parts of the histology slides the model focuses on – specifically meaningful areas such as nuclear clusters and gland borders. This approach represents a balanced trade-off between accuracy, speed and interpretability, making it a potentially useful tool for digital pathology and clinical decision support in the diagnosis of gastric cancer.