• Stars
    star
    271
  • Rank 150,835 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Keras implementation of ArcFace, CosFace, and SphereFace

Keras implementation of ArcFace, CosFace, and SphereFace

This repository contains code for ArcFace, CosFace, and SphereFace based on ArcFace: Additive Angular Margin Loss for Deep Face Recognition implemented in Keras.

Requirements

  • Python 3.6
  • Keras 2.2.4

Usage

Train

input = Input(shape=(28, 28, 1))
label = Input(shape=(10,))

x = Conv2D(32, kernel_size=(3, 3), activation='relu')(input)
x = MaxPooling2D(pool_size=(2, 2))(x)
x = Conv2D(64, kernel_size=(3, 3), activation='relu')(x)
x = MaxPooling2D(pool_size=(2, 2))(x)

x = BatchNormalization()(x)
x = Dropout(0.5)(x)
x = Flatten()(x)
x = Dense(512, kernel_initializer='he_normal')(x)
x = BatchNormalization()(x)
output = ArcFace(num_classes=10)([x, label])

model = Model([input, label], output)

model.compile(loss='categorical_crossentropy',
              optimizer=Adam(),
              metrics=['accuracy'])

model.fit([x_train, y_train],
          y_train,
          batch_size=batch_size,
          epochs=epochs,
          verbose=1,
          validation_data=([x_test, y_test], y_test),
          callbacks=[ModelCheckpoint('model.hdf5',
                     verbose=1, save_best_only=True)])

Test

model.load_weights('model.hdf5')
model = Model(inputs=model.input[0], outputs=model.layers[-3].output)
embedded_features = model.predict(x_test, verbose=1)
embedded_features /= np.linalg.norm(embedded_features, axis=1, keepdims=True)

Training

MNIST

ArcFace:

python train.py --arch vgg8_arcface

CosFace:

python train.py --arch vgg8_cosface

SphereFace:

python train.py --arch vgg8_sphereface

Results

MNIST

softmax arcface cosface sphereface

More Repositories

1

pytorch-nested-unet

PyTorch implementation of UNet++ (Nested U-Net).
Python
709
star
2

pytorch-deform-conv-v2

PyTorch implementation of Deformable ConvNets v2 (Modulated Deformable Convolution)
Python
654
star
3

pytorch-adacos

PyTorch implementation of AdaCos
Python
204
star
4

pytorch-auto-augment

PyTorch implementation of AutoAugment.
Python
148
star
5

pytorch-res2net

PyTorch implementation of Res2Net
Python
105
star
6

kaggle-aptos2019-blindness-detection

11th place solution for APTOS 2019 Blindness Detection on Kaggle (https://www.kaggle.com/c/aptos2019-blindness-detection).
Python
42
star
7

keras-cosine-annealing

Keras implementation of Cosine Annealing Scheduler
Python
41
star
8

pytorch-ricap

PyTorch implementation of RICAP (Random Image Cropping And Patching)
Python
37
star
9

keras-auto-augment

Keras implementation of AutoAugment.
Python
34
star
10

kaggle-pku-autonomous-driving

Part of 5th place solution for Peking University/Baidu - Autonomous Driving on Kaggle (https://www.kaggle.com/c/pku-autonomous-driving).
Python
21
star
11

pytorch-lars

PyTorch implementation of LARS (Layer-wise Adaptive Rate Scaling)
Python
16
star
12

tf-dark-pose

This is an unofficial TensorFlow implementation of DARK Pose (Distribution Aware Coordinate Representation for Human Pose Estimation).
Python
2
star
13

pytorch-scale-aware-triplet

PyTorch implementation of Scale-Aware Triplet Networks
Python
2
star
14

kaggle-carvana-image-masking-challenge

48th solution for Carvana image masking challenge on Kaggle (https://www.kaggle.com/c/carvana-image-masking-challenge).
Python
1
star
15

chainer-m2det

Chainer implementation of M2Det.
Python
1
star