Commit b2ee7d5c authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

[pre-commit] fix pre-commit complaints

parent 06c797fe
Pipeline #49168 passed with stages
in 4 minutes and 45 seconds
import math
import numbers
import tensorflow as tf
import math
from tensorflow.keras.layers import BatchNormalization
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
from tensorflow.keras.layers import GlobalAvgPool2D
def _check_input(
......@@ -164,7 +168,7 @@ def Normalize(mean, std=1.0, **kwargs):
class SphereFaceLayer(tf.keras.layers.Layer):
"""
r"""
Implements the SphereFace loss from equation (7) of `SphereFace: Deep Hypersphere Embedding for Face Recognition <https://arxiv.org/abs/1704.08063>`_
If the parameter `original` is set to `True` it will computes exactly what's written in eq (7): :math:`\\text{soft}(x_i) = \\frac{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi})))}{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi}))) + \sum_{j;j\\neq yi} exp(||x_i||\\text{cos}(\psi(\\theta_{j}))) }`.
......@@ -256,15 +260,6 @@ class ModifiedSoftMaxLayer(tf.keras.layers.Layer):
return logits
from tensorflow.keras.layers import (
BatchNormalization,
Dropout,
Dense,
Concatenate,
GlobalAvgPool2D,
)
def add_bottleneck(model, bottleneck_size=128, dropout_rate=0.2):
"""
Amend a bottleneck layer to a Keras Model
......
from .alexnet import AlexNet_simplified
from .arcface import ArcFaceLayer
from .arcface import ArcFaceLayer3Penalties
from .arcface import ArcFaceModel
from .densenet import DeepPixBiS
from .densenet import DenseNet
from .densenet import densenet161 # noqa: F401
from .mine import MineModel
from .embedding_validation import EmbeddingValidation
from .arcface import ArcFaceLayer, ArcFaceLayer3Penalties, ArcFaceModel
from .mine import MineModel
# gets sphinx autodoc done right - don't remove it
def __appropriate__(*args):
......
import math
import tensorflow as tf
from .embedding_validation import EmbeddingValidation
from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings
import math
from .embedding_validation import EmbeddingValidation
class ArcFaceModel(EmbeddingValidation):
......@@ -148,4 +151,3 @@ class ArcFaceLayer3Penalties(tf.keras.layers.Layer):
logits = self.s * logits
return logits
import tensorflow as tf
from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings
......@@ -10,7 +11,8 @@ class EmbeddingValidation(tf.keras.Model):
"""
def compile(
self, **kwargs,
self,
**kwargs,
):
"""
Compile
......@@ -29,7 +31,6 @@ class EmbeddingValidation(tf.keras.Model):
logits, _ = self(X, training=True)
loss = self.loss(y, logits)
trainable_vars = self.trainable_variables
self.optimizer.minimize(loss, self.trainable_variables, tape=tape)
self.compiled_metrics.update_state(y, logits, sample_weight=None)
......
from bob.learn.tensorflow.models import (
EmbeddingValidation,
ArcFaceLayer,
ArcFaceModel,
ArcFaceLayer3Penalties,
)
from bob.learn.tensorflow.layers import (
SphereFaceLayer,
ModifiedSoftMaxLayer,
)
import numpy as np
from bob.learn.tensorflow.layers import ModifiedSoftMaxLayer
from bob.learn.tensorflow.layers import SphereFaceLayer
from bob.learn.tensorflow.models import ArcFaceLayer
from bob.learn.tensorflow.models import ArcFaceLayer3Penalties
def test_arcface_layer():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment