All Projects → cvqluu → Angular Penalty Softmax Losses Pytorch

cvqluu / Angular Penalty Softmax Losses Pytorch

Licence: mit
Angular penalty loss functions in Pytorch (ArcFace, SphereFace, Additive Margin, CosFace)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Angular Penalty Softmax Losses Pytorch

Amsoftmax
A simple yet effective loss function for face verification.
Stars: ✭ 443 (+87.71%)
Mutual labels:  face-recognition, metric-learning
Facerecognize For Mobile Phone
适用于移动端的人脸识别模型,计算量与mobilefacenet相同,但megaface上提升了2%+
Stars: ✭ 229 (-2.97%)
Mutual labels:  face-recognition
Facerecognition
Implement face recognition using PCA, LDA and LPP
Stars: ✭ 206 (-12.71%)
Mutual labels:  face-recognition
Ownphotos
Self hosted alternative to Google Photos
Stars: ✭ 2,587 (+996.19%)
Mutual labels:  face-recognition
Face.evolve.pytorch
🔥🔥High-Performance Face Recognition Library on PaddlePaddle & PyTorch🔥🔥
Stars: ✭ 2,719 (+1052.12%)
Mutual labels:  face-recognition
Catalyst
Accelerated deep learning R&D
Stars: ✭ 2,804 (+1088.14%)
Mutual labels:  metric-learning
Ros people object detection tensorflow
An extensive ROS toolbox for object detection & tracking and face/action recognition with 2D and 3D support which makes your Robot understand the environment
Stars: ✭ 202 (-14.41%)
Mutual labels:  face-recognition
Person reid baseline pytorch
Pytorch ReID: A tiny, friendly, strong pytorch implement of object re-identification baseline. Tutorial 👉https://github.com/layumi/Person_reID_baseline_pytorch/tree/master/tutorial
Stars: ✭ 2,963 (+1155.51%)
Mutual labels:  metric-learning
Openface
Face recognition with deep neural networks.
Stars: ✭ 14,249 (+5937.71%)
Mutual labels:  face-recognition
Maskinsightface
基于人脸关键区域提取的人脸识别(LFW:99.82%+ CFP_FP:98.50%+ AgeDB30:98.25%+)
Stars: ✭ 221 (-6.36%)
Mutual labels:  face-recognition
Face recognition py
基于OpenCV的视频人脸识别
Stars: ✭ 215 (-8.9%)
Mutual labels:  face-recognition
Mobilefacenet pytorch
MobileFaceNets: Efficient CNNs for Accurate Real-Time Face Verification on Mobile Devices
Stars: ✭ 209 (-11.44%)
Mutual labels:  face-recognition
Insightface Tensorflow
Tensoflow implementation of InsightFace (ArcFace: Additive Angular Margin Loss for Deep Face Recognition).
Stars: ✭ 228 (-3.39%)
Mutual labels:  face-recognition
Esp32 Cam Webserver
Expanded version of the Espressif ESP webcam
Stars: ✭ 200 (-15.25%)
Mutual labels:  face-recognition
Get Me A Date
😍 Help me get a 💘 date tonight 🌛
Stars: ✭ 228 (-3.39%)
Mutual labels:  face-recognition
Pytorch Image Retrieval
A PyTorch framework for an image retrieval task including implementation of N-pair Loss (NIPS 2016) and Angular Loss (ICCV 2017).
Stars: ✭ 203 (-13.98%)
Mutual labels:  metric-learning
Magnetloss Pytorch
PyTorch implementation of a deep metric learning technique called "Magnet Loss" from Facebook AI Research (FAIR) in ICLR 2016.
Stars: ✭ 217 (-8.05%)
Mutual labels:  metric-learning
Faceimagequality
Code and information for face image quality assessment with SER-FIQ
Stars: ✭ 223 (-5.51%)
Mutual labels:  face-recognition
Facerecognition
Nextcloud app that implement a basic facial recognition system.
Stars: ✭ 226 (-4.24%)
Mutual labels:  face-recognition
Metric Learning Divide And Conquer
Source code for the paper "Divide and Conquer the Embedding Space for Metric Learning", CVPR 2019
Stars: ✭ 231 (-2.12%)
Mutual labels:  metric-learning

Angular Penalty Softmax Losses Pytorch

Concise Pytorch implementation of the Angular Penalty Softmax Losses presented in:

(Note: the SphereFace implementation is not exactly as described in their paper but instead uses the 'trick' presented in the ArcFace paper to use arccosine instead of the double angle formula)

from loss_functions import AngularPenaltySMLoss

in_features = 512
out_features = 10 # Number of classes

criterion = AngularPenaltySMLoss(in_features, out_features, loss_type='arcface') # loss_type in ['arcface', 'sphereface', 'cosface']

# Forward method works similarly to nn.CrossEntropyLoss
# x of shape (batch_size, in_features), labels of shape (batch_size,)
# labels should indicate class of each sample, and should be an int, l satisying 0 <= l < out_dim
loss = criterion(x, labels) 
loss.backward()

Experiments/Demo

There are a simple set of experiments on Fashion-MNIST [2] included in train_fMNIST.py which compares the use of ordinary Softmax and Additive Margin Softmax loss functions by projecting embedding features onto a 3D sphere.

The experiments can be run like so:

python train_fMNIST.py --num-epochs 40 --seed 1234 --use-cuda

Which produces the following results:

Baseline (softmax)

softmax

Additive Margin Softmax/CosFace

cosface

ArcFace

arcface

TODO: fix sphereface results

[1] Deng, J. et al. (2018) ‘ArcFace: Additive Angular Margin Loss for Deep Face Recognition’. Available at: http://arxiv.org/abs/1801.07698.

[2] Liu, W. et al. (2017) ‘SphereFace: Deep hypersphere embedding for face recognition’, in Proceedings - 30th IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, pp. 6738–6746. doi: 10.1109/CVPR.2017.713.

[3] Wang, H. et al. (2018) ‘CosFace: Large Margin Cosine Loss for Deep Face Recognition’. Available at: http://openaccess.thecvf.com/content_cvpr_2018/papers/Wang_CosFace_Large_Margin_CVPR_2018_paper.pdf (Accessed: 12 August 2019).

[4] “Additive Margin Softmax for Face Verification.” Wang, Feng, Jian Cheng, Weiyang Liu and Haijun Liu. IEEE Signal Processing Letters 25 (2018): 926-930.

[5] "Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms." Han Xiao, Kashif Rasul, Roland Vollgraf. arXiv:1708.07747

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].