Code Monkey home page Code Monkey logo

normsoftmax's Introduction

NormSoftmax

A PyTorch implementation of NormSoftmax based on BMVC 2019 paper Classification is a Strong Baseline for Deep Metric Learning.

Network Architecture

Requirements

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
  • thop
pip install thop

Datasets

CARS196, CUB200-2011, Standard Online Products and In-shop Clothes are used in this repo.

You should download these datasets by yourself, and extract them into ${data_path} directory, make sure the dir names are car, cub, sop and isc. Then run data_utils.py to preprocess them.

Usage

Train Model

python train.py --feature_dim 1024
optional arguments:
--data_path                   datasets path [default value is '/home/data']
--data_name                   dataset name [default value is 'car'](choices=['car', 'cub', 'sop', 'isc'])
--crop_type                   crop data or not, it only works for car or cub dataset [default value is 'uncropped'](choices=['uncropped', 'cropped'])
--lr                          learning rate [default value is 0.01]
--feature_dim                 feature dim [default value is 2048]
--temperature                 temperature used in softmax [default value is 0.05]
--recalls                     selected recall [default value is '1,2,4,8']
--batch_size                  train batch size [default value is 75]
--num_sample                  samples within each class [default value is 25]
--num_epochs                  train epoch number [default value is 30]

Test Model

python test.py --retrieval_num 10
optional arguments:
--query_img_name              query image name [default value is '/home/data/car/uncropped/008055.jpg']
--data_base                   queried database [default value is 'car_uncropped_2048_data_base.pth']
--retrieval_num               retrieval number [default value is 8]

Benchmarks

The models are trained on one NVIDIA Tesla V100 (32G) GPU, all the hyper-parameters are same with the paper.

Model Parameters and FLOPs (Params | FLOPs)

Backbone CARS196 CUB200 SOP In-shop
ResNet50 27.91M | 4.12G 27.91M | 4.12G 50.88M | 4.12G 35.89M | 4.12G

CARS196 (Uncropped | Cropped)

Feature Type R@1 R@2 R@4 R@8 Download Link
Dense 86.1% | 91.4% 91.9% | 95.0% 95.4% | 97.1% 97.4% | 98.3% gcmw | fygj
Binary 85.2% | 90.6% 91.6% | 94.6% 95.2% | 96.9% 97.3% | 98.2% gcmw | fygj

CUB200 (Uncropped | Cropped)

Feature Type R@1 R@2 R@4 R@8 Download Link
Dense 64.1% | 68.4% 75.4% | 79.9% 83.6% | 87.6% 90.6% | 92.9% qkjs | h37y
Binary 62.7% | 66.8% 74.4% | 78.7% 82.8% | 87.2% 90.0% | 92.7% qkjs | h37y

SOP

Feature Type R@1 R@10 R@100 R@1000 Download Link
Dense 78.7% 91.1% 96.5% 98.9% 3qr7
Binary 77.8% 90.7% 96.3% 98.8% 3qr7

In-shop

Feature Type R@1 R@10 R@20 R@30 R@40 R@50 Download Link
Dense 88.4% 97.5% 98.3% 98.7% 98.9% 99.0% 5wja
Binary 87.6% 97.4% 98.3% 98.6% 98.7% 98.9% 5wja

Results

CAR/CUB (Uncropped | Cropped)

CAR/CUB

SOP/ISC

SOP/ISC

normsoftmax's People

Contributors

leftthomas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.