GitPedia

PyTorch Image Retrieval

A PyTorch framework for an image retrieval task including implementation of N-pair Loss (NIPS 2016) and Angular Loss (ICCV 2017).

From leeesangwon·Updated April 2, 2026·View on GitHub·

A PyTorch framework for an image retrieval task including implementation of [N-pair Loss (NIPS 2016)](http://papers.nips.cc/paper/6199-improved-deep-metric-learning-with-multi-class-n-pair-loss-objective) and [Angular Loss (ICCV 2017)](https://arxiv.org/pdf/1708.01682.pdf). The project is written primarily in Python, distributed under the MIT License license, first published in 2019. Key topics include: angular-loss, deep-metric-learning, image-retrieval, metric-learning, n-pair-loss.

PyTorch Image Retrieval

A PyTorch framework for an image retrieval task including implementation of N-pair Loss (NIPS 2016) and Angular Loss (ICCV 2017).

Loss functions

We implemented loss functions to train the network for image retrieval.
Batch sampler for the loss function borrowed from here.

  • N-pair Loss (NIPS 2016): Sohn, Kihyuk. "Improved Deep Metric Learning with Multi-class N-pair Loss Objective," Advances in Neural Information
    Processing Systems. 2016.
  • Angular Loss (ICCV 2017): Wang, Jian. "Deep Metric Learning with Angular Loss," ICCV, 2017

Self-attention module

We attached the self-attention module of the Self-Attention GAN to conventional classification networks (e.g. DenseNet, ResNet, or SENet).
Implementation of the module borrowed from here.

Data augmentation

We adopted data augmentation techniques used in Single Shot MultiBox Detector.

Post processing

We utilized the following post-processing techniques in the inference phase.

Contributors

Showing top 3 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from leeesangwon/PyTorch-Image-Retrieval via the GitHub API.Last fetched: 6/20/2026