GeDML is an easy-to-use generalized deep metric learning library

Overview

Logo

Documentation build

News

  • [2021-9-6]: v0.0.0 has been released.

Introduction

GeDML is an easy-to-use generalized deep metric learning library, which contains:

  • State-of-the-art DML algorithms: We contrain 18+ losses functions and 6+ sampling strategies, and divide these algorithms into three categories (i.e., collectors, selectors, and losses).
  • Bridge bewteen DML and SSL: We attempt to bridge the gap between deep metric learning and self-supervised learning through specially designed modules, such as collectors.
  • Auxiliary modules to assist in building: We also encapsulates the upper interface for users to start programs quickly and separates the codes and configs for managing hyper-parameters conveniently.

Installation

Pip

pip install gedml

Framework

This project is modular in design. The pipeline diagram is as follows:

Pipeline

Code structure

  • _debug: Debug files.
  • demo: Demos of configuration files.
  • docs: Documentation.
  • src: Source code.
    • core: Losses, selectors, collectors, etc.
    • client: Tmux manager.
    • config: Config files including link, convert, assert and params.
    • launcher: Manager, Trainer, Tester, etc.
    • recorder: Recorder.

Method

Collectors

method description
BaseCollector Base class
DefaultCollector Do nothing
ProxyCollector Maintain a set of proxies
MoCoCollector paper: Momentum Contrast for Unsupervised Visual Representation Learning
SimSiamCollector paper: Exploring Simple Siamese Representation Learning
HDMLCollector paper: Hardness-Aware Deep Metric Learning
DAMLCollector paper: Deep Adversarial Metric Learning
DVMLCollector paper: Deep Variational Metric Learning

Losses

classifier-based

method description
CrossEntropyLoss Cross entropy loss for unsupervised methods
LargeMarginSoftmaxLoss paper: Large-Margin Softmax Loss for Convolutional Neural Networks
ArcFaceLoss paper: ArcFace: Additive Angular Margin Loss for Deep Face Recognition
CosFaceLoss paper: CosFace: Large Margin Cosine Loss for Deep Face Recognition

pair-based

method description
ContrastiveLoss paper: Learning a Similarity Metric Discriminatively, with Application to Face Verification
MarginLoss paper: Sampling Matters in Deep Embedding Learning
TripletLoss paper: Learning local feature descriptors with triplets and shallow convolutional neural networks
AngularLoss paper: Deep Metric Learning with Angular Loss
CircleLoss paper: Circle Loss: A Unified Perspective of Pair Similarity Optimization
FastAPLoss paper: Deep Metric Learning to Rank
LiftedStructureLoss paper: Deep Metric Learning via Lifted Structured Feature Embedding
MultiSimilarityLoss paper: Multi-Similarity Loss With General Pair Weighting for Deep Metric Learning
NPairLoss paper: Improved Deep Metric Learning with Multi-class N-pair Loss Objective
SignalToNoiseRatioLoss paper: Signal-To-Noise Ratio: A Robust Distance Metric for Deep Metric Learning
PosPairLoss paper: Exploring Simple Siamese Representation Learning

proxy-based

method description
ProxyLoss paper: No Fuss Distance Metric Learning Using Proxies
ProxyAnchorLoss paper: Proxy Anchor Loss for Deep Metric Learning
SoftTripleLoss paper: SoftTriple Loss: Deep Metric Learning Without Triplet Sampling

Selectors

method description
BaseSelector Base class
DefaultSelector Do nothing
DenseTripletSelector Select all triples
DensePairSelector Select all pairs

Quickstart

Please set the environment variable WORKSPACE first to indicate where to manage your project.

Initialization

Use ConfigHandler to create all objects.

config_handler = ConfigHandler()
config_handler.get_params_dict()
objects_dict = config_handler.create_all()

Start

Use manager to automatically call trainer and tester.

manager = utils.get_default(objects_dict, "managers")
manager.run()

Directly use trainer and tester.

trainer = utils.get_default(objects_dict, "trainers")
tester = utils.get_default(objects_dict, "testers")
recorder = utils.get_default(objects_dict, "recorders")

# start to train
utils.func_params_mediator(
    [objects_dict],
    trainer.__call__
)

# start to test
metrics = utils.func_params_mediator(
    [
        {"recorders": recorder},
        objects_dict,
    ],
    tester.__call__
)

Document

For more information, please refer to:

📖 👉 Docs

Some specific guidances:

Configs

We will continually update the optimal parameters of different configs in TsinghuaCloud

Code Reference

TODO:

  • assert parameters
  • distributed methods and Non-distributed methods!!!
  • write github action to automate unit-test, package publish and docs building.
  • add cross-validation splits protocol.
You might also like...
Fast image augmentation library and easy to use wrapper around other libraries. Documentation:  https://albumentations.ai/docs/ Paper about library: https://www.mdpi.com/2078-2489/11/2/125
Fast image augmentation library and easy to use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about library: https://www.mdpi.com/2078-2489/11/2/125

Albumentations Albumentations is a Python library for image augmentation. Image augmentation is used in deep learning and computer vision tasks to inc

 Audio-Visual Generalized Few-Shot Learning with Prototype-Based Co-Adaptation
Audio-Visual Generalized Few-Shot Learning with Prototype-Based Co-Adaptation

Audio-Visual Generalized Few-Shot Learning with Prototype-Based Co-Adaptation The code repository for "Audio-Visual Generalized Few-Shot Learning with

Generalized Jensen-Shannon Divergence Loss for Learning with Noisy Labels

The official code for the NeurIPS 2021 paper Generalized Jensen-Shannon Divergence Loss for Learning with Noisy Labels

Learning hidden low dimensional dyanmics using a Generalized Onsager Principle and neural networks

OnsagerNet Learning hidden low dimensional dyanmics using a Generalized Onsager Principle and neural networks This is the original pyTorch implemenati

An Easy-to-use, Modular and Prolongable package of deep-learning based Named Entity Recognition Models.

DeepNER An Easy-to-use, Modular and Prolongable package of deep-learning based Named Entity Recognition Models. This repository contains complex Deep

An efficient and easy-to-use deep learning model compression framework
An efficient and easy-to-use deep learning model compression framework

TinyNeuralNetwork 简体中文 TinyNeuralNetwork is an efficient and easy-to-use deep learning model compression framework, which contains features like neura

this is a lite easy to use virtual keyboard project for anyone to use
this is a lite easy to use virtual keyboard project for anyone to use

virtual_Keyboard this is a lite easy to use virtual keyboard project for anyone to use motivation I made this for this year's recruitment for RobEn AA

Metric learning algorithms in Python

metric-learn: Metric Learning in Python metric-learn contains efficient Python implementations of several popular supervised and weakly-supervised met

Code reproduce for paper
Code reproduce for paper "Vehicle Re-identification with Viewpoint-aware Metric Learning"

VANET Code reproduce for paper "Vehicle Re-identification with Viewpoint-aware Metric Learning" Introduction This is the implementation of article VAN

Comments
  • About the parameter information storage.

    About the parameter information storage.

    It will be more friendly to save the key parameter information in the experiments (like in a txt file) in order not to forget the parameter and it is easier to check the parameter for comparison.

    opened by wangck20 1
Owner
Borui Zhang
I am a first year Ph.D student in the Department of Automation at THU. My research direction is computer vision.
Borui Zhang
This is the repository for CVPR2021 Dynamic Metric Learning: Towards a Scalable Metric Space to Accommodate Multiple Semantic Scales

Intro This is the repository for CVPR2021 Dynamic Metric Learning: Towards a Scalable Metric Space to Accommodate Multiple Semantic Scales Vehicle Sam

null 39 Jul 21, 2022
Official PyTorch implementation of "Proxy Synthesis: Learning with Synthetic Classes for Deep Metric Learning" (AAAI 2021)

Proxy Synthesis: Learning with Synthetic Classes for Deep Metric Learning Official PyTorch implementation of "Proxy Synthesis: Learning with Synthetic

NAVER/LINE Vision 30 Dec 6, 2022
A collection of easy-to-use, ready-to-use, interesting deep neural network models

Interesting and reproducible research works should be conserved. This repository wraps a collection of deep neural network models into a simple and un

Aria Ghora Prabono 16 Jun 16, 2022
Dogs classification with Deep Metric Learning using some popular losses

Tsinghua Dogs classification with Deep Metric Learning 1. Introduction Tsinghua Dogs dataset Tsinghua Dogs is a fine-grained classification dataset fo

QuocThangNguyen 45 Nov 9, 2022
Towards Interpretable Deep Metric Learning with Structural Matching

DIML Created by Wenliang Zhao*, Yongming Rao*, Ziyi Wang, Jiwen Lu, Jie Zhou This repository contains PyTorch implementation for paper Towards Interpr

Wenliang Zhao 75 Nov 11, 2022
[ICCV 2021] Official PyTorch implementation for Deep Relational Metric Learning.

Deep Relational Metric Learning This repository is the official PyTorch implementation of Deep Relational Metric Learning. Framework Datasets CUB-200-

Borui Zhang 39 Dec 10, 2022
A Pytorch implementation of "Manifold Matching via Deep Metric Learning for Generative Modeling" (ICCV 2021)

Manifold Matching via Deep Metric Learning for Generative Modeling A Pytorch implementation of "Manifold Matching via Deep Metric Learning for Generat

null 69 Dec 10, 2022
Unofficial implementation of Proxy Anchor Loss for Deep Metric Learning

Proxy Anchor Loss for Deep Metric Learning Unofficial pytorch, tensorflow and mxnet implementations of Proxy Anchor Loss for Deep Metric Learning. Not

Geonmo Gu 3 Jun 9, 2021
Near-Duplicate Video Retrieval with Deep Metric Learning

Near-Duplicate Video Retrieval with Deep Metric Learning This repository contains the Tensorflow implementation of the paper Near-Duplicate Video Retr

null 2 Jan 24, 2022
A Lighting Pytorch Framework for Recommendation System, Easy-to-use and Easy-to-extend.

Torch-RecHub A Lighting Pytorch Framework for Recommendation Models, Easy-to-use and Easy-to-extend. 安装 pip install torch-rechub 主要特性 scikit-learn风格易用

Mincai Lai 67 Jan 4, 2023