STIR: Siamese Transformer for Image Retrieval Postprocessing

26 Apr 2023  ·  Aleksei Shabanov, Aleksei Tarasov, Sergey Nikolenko ·

Current metric learning approaches for image retrieval are usually based on learning a space of informative latent representations where simple approaches such as the cosine distance will work well. Recent state of the art methods such as HypViT move to more complex embedding spaces that may yield better results but are harder to scale to production environments. In this work, we first construct a simpler model based on triplet loss with hard negatives mining that performs at the state of the art level but does not have these drawbacks. Second, we introduce a novel approach for image retrieval postprocessing called Siamese Transformer for Image Retrieval (STIR) that reranks several top outputs in a single forward pass. Unlike previously proposed Reranking Transformers, STIR does not rely on global/local feature extraction and directly compares a query image and a retrieved candidate on pixel level with the usage of attention mechanism. The resulting approach defines a new state of the art on standard image retrieval datasets: Stanford Online Products and DeepFashion In-shop. We also release the source code at and an interactive demo of our approach at

PDF Abstract

Results from the Paper

Task Dataset Model Metric Name Metric Value Global Rank Result Benchmark
Metric Learning In-Shop STIR R@1 95 # 2
Metric Learning In-Shop ViT-Triplet R@1 92.1 # 9
Metric Learning Stanford Online Products STIR R@1 88.3 # 2
Metric Learning Stanford Online Products ViT-Triplet R@1 86.5 # 4