keras-team / keras-cv

Industry-strength Computer Vision workflows with Keras
Other
1.01k stars 330 forks source link

Add ArcFace loss. #546

Closed innat closed 1 year ago

innat commented 2 years ago

System information.

TensorFlow version (you are using): 2.8 Are you willing to contribute it (Yes/No) : No (but willing to provide starter if required.)

Describe the feature and the current behavior/state.

ArcFace, or Additive Angular Margin Loss, is a loss function used mainly in face recognition tasks. It is used to obtain highly discriminative features. This loss function can be used in both vision task and nlp task. So, I think its general for keras_cv and keras_nlp.

Paper: https://arxiv.org/pdf/1801.07698.pdf, TL,DR, https://paperswithcode.com/method/arcface Citation: 2939 (current)

Will this change the current api? How?


tf.keras.losses.SparseArcFace
tf.keras.losses.CategoricalArcFace

Who will benefit from this feature?

keras practitioners.

Contributing

fchollet commented 2 years ago

ArcFace, or Additive Angular Margin Loss, is a loss function used mainly in face recognition tasks

What are some NLP use cases? It seems like it might be a good fit for KerasCV specifically.

innat commented 2 years ago

Sorry I miswrote, it should be only CV task. Could you please move this issue to KerasCV?

ayulockin commented 2 years ago

Hey, @LukeWood @sayakpaul I think this would be a great feature addition to KerasCV. It's especially popular in Kaggle competitions for reference.

Please assign it to me.

sayakpaul commented 2 years ago

I concur. Especially for retrieval tasks, ArcFace loss is greatly beneficial.

LukeWood commented 2 years ago

interesting, can this be used with the existing models we have? i.e. if we add this will we have the tools we need to support facial recognition?

sayakpaul commented 2 years ago

Should be compatible with existing models.

LukeWood commented 2 years ago

So theoretically, we include this, and use this loss to create a facial recognition tutorial with the other existing components?

sayakpaul commented 2 years ago

Shoul be the case. We have a tutorial on few-shot learning and we coul definitely take some components from that too.

LukeWood commented 2 years ago

Shoul be the case. We have a tutorial on few-shot learning and we coul definitely take some components from that too.

ok, sounds good. Then I think this is a great component. Especially if we can include a tutorial on facial recognition.

sayakpaul commented 2 years ago

@ayulockin take it for the grab if you're up.

LukeWood commented 2 years ago

When we do include this I do think it’s important to have a tutorial showing off how to use it, so let’s keep that in mind! Doesn’t have to be anything crazy, just some basics!

ayulockin commented 2 years ago

This loss is compatible with existing models.

I can take this up. Will start working on it soon. Also the idea of tutorial is great for this loss.

yashchks87 commented 1 year ago

Would love to work on this if no one has picked up still.

alexandrekj commented 1 year ago

Any updates on this?

jbischof commented 1 year ago

It looks like this fell through the cracks @alexandrekj. @yashchks87 or @alexandrekj, are either of you interested in working on this?

yashchks87 commented 1 year ago

I can take on it. @jbischof