The problem I am trying to solve is, given two images, determining whether they contain the same object or not. Here is an example:
The first two images contain the same object, while the third image contains a similar, but different object. My goal is for the first two images to be seen as a match, but the first and third (and second and third) being seen as not matching. I want the matching to work in general with any object. It should be able to tell if any two pictures of any two objects are identical objects (not just similar) even if they are taken at different angles, cameras, and lighting conditions.
I've tried using the SIFT algorithm to find keypoints and descriptors. Then using the cv2.findHomography function with RANSAC to get the inliners. This doesn't really work, and I haven't been able to get it to output good keypoints or matches. They are basically garbage.
I've also tried using a pretrained model (like ResNet50) and removing the last few output layers (using include_top=False for the model in the python keras library). Then I can calculate the cosine similarity between the flattened output tensors of the model for both images. This gives good results for determining if two images contain similar objects, but not for determining if they are the same object.
Recently, I've been trying to do transfer learning from the pretrained imagenet model to a siamese convolutional neural network using the triplet loss function. I followed this tutorial https://keras.io/examples/vision/siamese_network/ and it works well. My issue is that I cannot find a dataset that I could use to train it to identify identical objects. I've tried to curate my own dataset, but it is too time consuming for me to do alone.
Overall, I have tried many approaches. The siamese network should work, but I don't have a dataset to train on. Any help would be greatly appreciated.
Update