Skip to content

This repository contains the project where I contributed to the TensorFlow Team during GSoC in the year 2022.

License

Notifications You must be signed in to change notification settings

aylinaydincs/GSoC-22-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GSoC-22-Project

This repository contains the project where I contributed to the TensorFlow Team during GSoC in the year 2022.

GSoC'22 Project Link

Mentor:

  • Special thanks to Yusuf Sarıgoz @monatis for being perfect mentor.

Google Summer of Code Proposal:

Proposal

Pull-request Link:

tensorflow/similarity#291

ArcFace Loss

Additive Angular Margin Loss (ArcFace) has a clear geometric interpretation due to the exact correspondence to the geodesic distance on the hypersphere, and consistently outperforms the state-of-the-art and can be easily implemented with negligible computational overhead.

Standalone usage:

    import tensorflow as tf
    import tensorflow_similarity as tfsim

    labels = tf.Variable([1, 0])
    embeddings = tf.Variable([[0.2, 0.3, 0.1], [0.4, 0.5, 0.5]])
    
    #create loss according to your data
    loss_fn = tfsim.losses.ArcFaceLoss(num_classes=2, embedding_size=3)
    loss = loss_fn(labels, embeddings)

Usage with Model:

    import tensorflow as tf
    import tensorflow_similarity as tfsim
    
    #extract the required variable
    num_classes = np.unique(y_train).size
    embedding_size = model.get_layer('metric_embedding').output.shape[1]
    
    #create loss according to your data
    loss = tfsim.losses.ArcFaceLoss(num_classes= num_classes, embedding_size=embedding_size, name="ArcFaceLoss")
    
    #compile your model with your loss
    model.compile(optimizer=tf.keras.optimizers.SGD(LR), loss=loss, distance=distance)

Original Paper:

ArcFace: Additive Angular Margin Loss for Deep Face Recognition.

Offical Implementation of Paper:

MXNet

Medium Stories of Project

License

Apache License 2.0

About

This repository contains the project where I contributed to the TensorFlow Team during GSoC in the year 2022.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published