Distance-Ratio-Based Formulation for Metric Learning

Overview

Distance-Ratio-Based Formulation for Metric Learning

Environment

Preparing datasets

CUB

  • Change directory to /filelists/CUB
  • run source ./download_CUB.sh

One might need to manually download CUB data from http://www.vision.caltech.edu/visipedia-data/CUB-200-2011/CUB_200_2011.tgz.

mini-ImageNet

  • Change directory to /filelists/miniImagenet
  • run source ./download_miniImagenet.sh (WARNING: This would download the 155G ImageNet dataset.)

To only download 'miniImageNet dataset' and not the whole 155G ImageNet dataset:

(Download 'csv' files from the codes in /filelists/miniImagenet/download_miniImagenet.sh. Then, do the following.)

First, download zip file from https://drive.google.com/file/d/0B3Irx3uQNoBMQ1FlNXJsZUdYWEE/view (It is from https://github.com/oscarknagg/few-shot). After unzipping the zip file at /filelists/miniImagenet, run a script /filelists/miniImagenet/prepare_mini_imagenet.py which is modified from https://github.com/oscarknagg/few-shot/blob/master/scripts/prepare_mini_imagenet.py. Then, run /filelists/miniImagenet/write_miniImagenet_filelist2.py.

Train

Run python ./train.py --dataset [DATASETNAME] --model [BACKBONENAME] --method [METHODNAME] --train_aug [--OPTIONARG]

To also save training analyses results, for example, run python ./train.py --dataset miniImagenet --model Conv4 --method protonet_S --train_aug --n_shot 5 --train_n_way 5 --test_n_way 5 > record/miniImagenet_Conv4_proto_S_5s5w.txt

train_models.ipynb contains codes for our experiments.

Save features

Save the extracted feature before the classifaction layer to increase test speed.

For instance, run python ./save_features.py --dataset miniImagenet --model Conv4 --method protonet_S --train_aug --n_shot 5 --train_n_way 5

Test

For example, run python ./test.py --dataset miniImagenet --model Conv4 --method protonet_S --train_aug --n_shot 5 --train_n_way 5 --test_n_way 5

Analyze training

Run /record/analyze_training_1shot.ipynb and /record/analyze_training_5shot.ipynb to analyze training results (norm ratio, con-alpha ratio, div-alpha ratio, and con-div ratio)

Results

The test results will be recorded in ./record/results.txt

Visual comparison of softmax-based and distance-ratio-based (DR) formulation

The following images visualize confidence scores of red class when the three points are the representing points of red, green, and blue classes.

Softmax-based formulation DR formulation

References and licence

Our repository (a set of codes) is forked from an original repository (https://github.com/wyharveychen/CloserLookFewShot) and codes are under the same licence (LICENSE.txt) as the original repository except for the following.

/filelists/miniImagenet/prepare_mini_imagenet.py file is modifed from https://github.com/oscarknagg/few-shot. It is under a different licence in /filelists/miniImagenet/prepare_mini_imagenet.LICENSE

Copyright and licence notes (including the copyright note in /data/additional_transforms.py) are from the original repositories (https://github.com/wyharveychen/CloserLookFewShot and https://github.com/oscarknagg/few-shot).

Modifications

List of modified or added files (or folders) compared to the original repository (https://github.com/wyharveychen/CloserLookFewShot):

io_utils.py backbone.py configs.py train.py save_features.py test.py utils.py README.md train_models.ipynb /methods/__init__.py /methods/protonet_S.py /methods/meta_template.py /methods/protonet_DR.py /methods/softmax_1nn.py /methods/DR_1nn.py /models/ /filelists/miniImagenet/prepare_mini_imagenet.py /filelists/miniImagenet/prepare_mini_imagenet.LICENSE /filelists/miniImagenet/write_miniImagenet_filelist2.py /record/ /record/preprocessed/ /record/analyze_training_1shot.ipynb /record/analyze_training_5shot.ipynb

My (Hyeongji Kim) main contributions (modifications) are in /methods/meta_template.py, /methods/protonet_DR.py, /methods/softmax_1nn.py, /methods/DR_1nn.py, /record/analyze_training_1shot.ipynb, and /record/analyze_training_5shot.ipynb.

Owner
Hyeongji Kim
Hyeongji Kim
GE2340 project source code without credentials.

GE2340-Project-Public GE2340 project source code without credentials. Run the bot.py to start the bot Telegram: @jasperwong_ge2340_bot If the bot does

0 Feb 10, 2022
AttentionGAN for Unpaired Image-to-Image Translation & Multi-Domain Image-to-Image Translation

AttentionGAN-v2 for Unpaired Image-to-Image Translation AttentionGAN-v2 Framework The proposed generator learns both foreground and background attenti

Hao Tang 530 Dec 27, 2022
Optimizing Value-at-Risk and Conditional Value-at-Risk of Black Box Functions with Lacing Values (LV)

BayesOpt-LV Optimizing Value-at-Risk and Conditional Value-at-Risk of Black Box Functions with Lacing Values (LV) About This repository contains the s

1 Nov 11, 2021
This is the official PyTorch implementation for "Mesa: A Memory-saving Training Framework for Transformers".

A Memory-saving Training Framework for Transformers This is the official PyTorch implementation for Mesa: A Memory-saving Training Framework for Trans

Zhuang AI Group 105 Dec 06, 2022
git《Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser》(2021) GitHub: [fig5]

Pseudo-ISP: Learning Pseudo In-camera Signal Processing Pipeline from A Color Image Denoiser Abstract The success of deep denoisers on real-world colo

Yue Cao 51 Nov 22, 2022
RSC-Net: 3D Human Pose, Shape and Texture from Low-Resolution Images and Videos

RSC-Net: 3D Human Pose, Shape and Texture from Low-Resolution Images and Videos Implementation for "3D Human Pose, Shape and Texture from Low-Resoluti

XiangyuXu 42 Nov 10, 2022
We will release the code of "ConTNet: Why not use convolution and transformer at the same time?" in this repo

ConTNet Introduction ConTNet (Convlution-Tranformer Network) is proposed mainly in response to the following two issues: (1) ConvNets lack a large rec

93 Nov 08, 2022
Collection of TensorFlow2 implementations of Generative Adversarial Network varieties presented in research papers.

TensorFlow2-GAN Collection of tf2.0 implementations of Generative Adversarial Network varieties presented in research papers. Model architectures will

41 Apr 28, 2022
Pytoydl: A toy deep learning framework built upon numpy.

Documents: https://pytoydl.readthedocs.io/zh/latest/ Pytoydl A toy deep learning framework built upon numpy. You can star this repository to keep trac

28 Dec 10, 2022
WormMovementSimulation - 3D Simulation of Worm Body Movement with Neurons attached to its body

Generate 3D Locomotion Data This module is intended to create 2D video trajector

1 Aug 09, 2022
WSDM2022 Challenge - Large scale temporal graph link prediction

WSDM 2022 Large-scale Temporal Graph Link Prediction - Baseline and Initial Test Set WSDM Cup Website link Link to this challenge This branch offers A

Deep Graph Library 34 Dec 29, 2022
A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising (CVPR 2020 Oral & TPAMI 2021)

ELD The implementation of CVPR 2020 (Oral) paper "A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising" and its journal (TPAMI) v

Kaixuan Wei 359 Jan 01, 2023
ICON: Implicit Clothed humans Obtained from Normals

ICON: Implicit Clothed humans Obtained from Normals arXiv, December 2021. Yuliang Xiu · Jinlong Yang · Dimitrios Tzionas · Michael J. Black Table of C

Yuliang Xiu 1.1k Dec 30, 2022
A full pipeline AutoML tool for tabular data

HyperGBM Doc | 中文 We Are Hiring! Dear folks,we are offering challenging opportunities located in Beijing for both professionals and students who are k

DataCanvas 240 Jan 03, 2023
PyTorch implementation(s) of various ResNet models from Twitch streams.

pytorch-resnet-twitch PyTorch implementation(s) of various ResNet models from Twitch streams. Status: ResNet50 currently not working. Will update in n

Daniel Bourke 3 Jan 11, 2022
Implementations of polygamma, lgamma, and beta functions for PyTorch

lgamma Implementations of polygamma, lgamma, and beta functions for PyTorch. It's very hacky, but that's usually ok for research use. To build, run: .

Rachit Singh 24 Nov 09, 2021
Official implementation for ICDAR 2021 paper "Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer"

Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer Description Convert offline handwritten mathematical expressi

Wenqi Zhao 87 Dec 27, 2022
Converts geometry node attributes to built-in attributes

Attribute Converter Simplifies converting attributes created by geometry nodes to built-in attributes like UVs or vertex colors, as a single click ope

Ivan Notaros 12 Dec 22, 2022
Implementation of the state-of-the-art vision transformers with tensorflow

ViT Tensorflow This repository contains the tensorflow implementation of the state-of-the-art vision transformers (a category of computer vision model

Mohammadmahdi NouriBorji 2 Mar 16, 2022
Neural implicit reconstruction experiments for the Vector Neuron paper

Neural Implicit Reconstruction with Vector Neurons This repository contains code for the neural implicit reconstruction experiments in the paper Vecto

Congyue Deng 35 Jan 02, 2023