GithubHelp home page GithubHelp logo

pake2070 / keras-arcface Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 4uiiurz1/keras-arcface

0.0 0.0 0.0 453 KB

Keras implementation of ArcFace, CosFace, and SphereFace

License: MIT License

Python 100.00%

keras-arcface's Introduction

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

keras-arcface's People

Contributors

4uiiurz1 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.