This repository presents two distinct methodologies for the detection of Helicobacter pylori (H. pylori) infections within histological images with immunohistochemical staining, leveraging two different deep learning methods. The implemented techniques include autoencoders and contrastive learning.
The autoencoder method involves training the model with negative images (images without the infection). During the training phase, the autoencoder learns to reconstruct the negative images accurately, but, when confronted with positive images containing H. pylori, the autoencoder encounters difficulty in accurately reconstructing the pertinent regions due to its exclusive exposure to negative examples.
By establishing a threshold for image features indicative of H. pylori presence, we can effectively classify images into positive and negative categories.
The second methodology employs contrastive learning, employing the triplet loss method.

Within this framework, the model is trained using triplets of samples, comprising an anchor image, a positive image, and a negative image. The model endeavors to discern between positive and negative samples by optimizing the distances between the anchor image and both positive and negative counterparts. Through this iterative training process, the model acquires the capability to distinguish features characteristic of H. pylori presence.
As observed in the previous figures, the model converges successfully and it's able to cluster correctly the two classes (infected and not infected).
The code for implementing the two approaches resides in the following folders:
- Autoencoder: Contains code related to the autoencoder approach.
- ContrastiveWithTripletLoss: Contains code related to the contrastive learning approach using triplet loss.
Feel free to explore the respective folders for more details on the implementation of each method.
We welcome contributions to enhance and improve this H. pylori detection project. If you have any suggestions, ideas, or improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.


