Face Recognition using FaceNet

  • Author: Johannes Maucher

  • Last update: 08.06.2021

Conventional methods for face recognition (before the rise of deep learning), are e.g. the Eigenface approach by Turk and Pentland: Face Recognition using Eigenfaces or the Fisherfaces approach by Belhumeur et al. Both of these approaches calculate a low-dimensional subspace from the high dimensonal image space. Once this subspace is determined, by PCA or FLDA, respectively, all images are transformed into this subspace and recognition, e.g. simple nearest-neighbour recognition, is performed there. See J. Maucher: Lecture Object Recognition for details on these approaches.

FaceNet is a CNN-based face recognition system that was introduced in FaceNet: A Unified Embedding for Face Recognition and Clustering. For a given image of a face, FaceNet calculates a vector of length 128, the so called face embedding. That is, similar as the conventional approaches, Eigenface and Fisherface, also FaceNet transforms the high-dimensional image space into a low-dimensional subspace. This low-dimensional embedding can be used as input for any supervised machine learning algorithm, e.g. a Support Vector Machine (SVM).

The overall process, implemented in this notebook, is summarized in this picture:

Drawing

Some fundamentals on FaceNET

FaceNet is a deep Convolutional Neural Network (CNN), which calculates from face-images at it’s input so called face-embeddings (vectors of length 128) at it’s output. FaceNet is trained such that the face-embedding vectors of images, which contain the same person, are close to each other and the vectors from images of different persons have a large euclidean distance in between.

Architecture

The authors of the FaceNet paper propose two different CNN architectures that can be applied. The first and less complex one is a CNN as introduced in Zeiler & Fergus: Visualizing and Understanding CNNs. The second one is an Inception-Net like introduced in Szegedy et al: Going deeper with convolutions (GoogLeNet). The pretrained-FaceNet CNN applied in this notebook is even more complex - the Inception-ResNet as introduced in Szegedy et al: Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning. Independent of the concrete CNN, the abstract architecture is as depicted below:

Drawing

Source: FaceNet paper

Triplet loss

The triplet loss is the most important part of the FaceNet approach. The authors put it as follows:

The triplet loss … directly reflects what we want to achieve in face verification, recognition and clustering. Namely, we strive for an embedding \(f(x)\), from an image \(x\) into a feature space \(\cal{R}^d\), such that the squared distance between all faces, independent of imaging conditions, of the same identity is small, whereas the squared distance beetween a pair of face images from different identities is large.

The goal of the triplet loss is to ensure that an image \(x_i^a\) (anchor) of a specific person is closer to all other images \(x_i^p\) (positive) of the same person than it is to any image \(x_i^n\) (negative) of any other person. This is visualized in the figure below:

Drawing

Source: FaceNet paper

More formally, the following relation shall be fulfilled:

\[ || f(x_i^a) - f(x_i^p) ||_2^2 + \alpha < || f(x_i^a) - f(x_i^n) ||_2^2, \quad \forall (f(x_i^a), f(x_i^p), f(x_i^n) \in \cal{T}, \]

where \(\alpha\) is a margin that is enforced between positive and negative pairs. This implies that the following loss function must be minimized:

\[ L=\sum\limits_{i=1}^N \left[ || f(x_i^a) - f(x_i^p) ||_2^2 - || f(x_i^a) - f(x_i^n) ||_2^2 + \alpha \right]. \]

If just all possible triplets \(\cal{T}\) are applied, training would converge slowly, because many triplets already fulfill the inequality-relation formulated above and won’t yield weight-adaptations. Therefore, the authors of the FaceNet paper suggest a specific triplet selection process such that for a given anchor \(x_i^a\) only those positives are selected, for which \(|| f(x_i^a) - f(x_i^p) ||_2^2\) is maximal and only those negatives are selected, for which \(|| f(x_i^a) - f(x_i^n) ||_2^2\) is minimal. For details please refer to FaceNet paper.

Apply pretrained FaceNet for calculating face embeddings

In this notebook a pre-trained Keras FaceNet model from this project https://github.com/nyoki-mtl/keras-facenet will be applied. The model itself must be downloaded from facenet_keras.h5. It was trained on MS-Celeb-1M dataset. The pre-trained model expects input images to

  • be color,

  • have their pixel values whitened (standardized across all three channels),

  • have a square shape of 160×160 pixels.

from architecture import *
from warnings import filterwarnings
filterwarnings("ignore")
model = InceptionResNetV2()
path = "weights/facenet_keras_weights.h5"
model.load_weights(path)
print(model.inputs)
print(model.outputs)
[<KerasTensor: shape=(None, 160, 160, 3) dtype=float32 (created by layer 'input_398')>]
[<KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'Bottleneck_BatchNorm')>]

The output of the previous code-cell tells that the input to FaceNet must be of shape \((160,160,3)\) and it’s output is a vector of length \(128\). The entire FaceNet architecture is summarized below. As can be seen FaceNet is a combination of inception-net and resnet.

model.summary()
Model: "inception_resnet_v1"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_398 (InputLayer)          [(None, 160, 160, 3) 0                                            
__________________________________________________________________________________________________
Conv2d_1a_3x3 (Conv2D)          (None, 79, 79, 32)   864         input_398[0][0]                  
__________________________________________________________________________________________________
Conv2d_1a_3x3_BatchNorm (BatchN (None, 79, 79, 32)   96          Conv2d_1a_3x3[0][0]              
__________________________________________________________________________________________________
Conv2d_1a_3x3_Activation (Activ (None, 79, 79, 32)   0           Conv2d_1a_3x3_BatchNorm[0][0]    
__________________________________________________________________________________________________
Conv2d_2a_3x3 (Conv2D)          (None, 77, 77, 32)   9216        Conv2d_1a_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Conv2d_2a_3x3_BatchNorm (BatchN (None, 77, 77, 32)   96          Conv2d_2a_3x3[0][0]              
__________________________________________________________________________________________________
Conv2d_2a_3x3_Activation (Activ (None, 77, 77, 32)   0           Conv2d_2a_3x3_BatchNorm[0][0]    
__________________________________________________________________________________________________
Conv2d_2b_3x3 (Conv2D)          (None, 77, 77, 64)   18432       Conv2d_2a_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Conv2d_2b_3x3_BatchNorm (BatchN (None, 77, 77, 64)   192         Conv2d_2b_3x3[0][0]              
__________________________________________________________________________________________________
Conv2d_2b_3x3_Activation (Activ (None, 77, 77, 64)   0           Conv2d_2b_3x3_BatchNorm[0][0]    
__________________________________________________________________________________________________
MaxPool_3a_3x3 (MaxPooling2D)   (None, 38, 38, 64)   0           Conv2d_2b_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Conv2d_3b_1x1 (Conv2D)          (None, 38, 38, 80)   5120        MaxPool_3a_3x3[0][0]             
__________________________________________________________________________________________________
Conv2d_3b_1x1_BatchNorm (BatchN (None, 38, 38, 80)   240         Conv2d_3b_1x1[0][0]              
__________________________________________________________________________________________________
Conv2d_3b_1x1_Activation (Activ (None, 38, 38, 80)   0           Conv2d_3b_1x1_BatchNorm[0][0]    
__________________________________________________________________________________________________
Conv2d_4a_3x3 (Conv2D)          (None, 36, 36, 192)  138240      Conv2d_3b_1x1_Activation[0][0]   
__________________________________________________________________________________________________
Conv2d_4a_3x3_BatchNorm (BatchN (None, 36, 36, 192)  576         Conv2d_4a_3x3[0][0]              
__________________________________________________________________________________________________
Conv2d_4a_3x3_Activation (Activ (None, 36, 36, 192)  0           Conv2d_4a_3x3_BatchNorm[0][0]    
__________________________________________________________________________________________________
Conv2d_4b_3x3 (Conv2D)          (None, 17, 17, 256)  442368      Conv2d_4a_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Conv2d_4b_3x3_BatchNorm (BatchN (None, 17, 17, 256)  768         Conv2d_4b_3x3[0][0]              
__________________________________________________________________________________________________
Conv2d_4b_3x3_Activation (Activ (None, 17, 17, 256)  0           Conv2d_4b_3x3_BatchNorm[0][0]    
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   8192        Conv2d_4b_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_1_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_1_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   8192        Conv2d_4b_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_1_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_1_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_1_Branch_2_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_1_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_1_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_1_Branch_0_Conv2d_1x1 ( (None, 17, 17, 32)   8192        Conv2d_4b_3x3_Activation[0][0]   
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_1_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   9216        Block35_1_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_1_Branch_0_Conv2d_1x1_B (None, 17, 17, 32)   96          Block35_1_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_1_Branch_1_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   96          Block35_1_Branch_2_Conv2d_0c_3x3[
__________________________________________________________________________________________________
Block35_1_Branch_0_Conv2d_1x1_A (None, 17, 17, 32)   0           Block35_1_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block35_1_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_1_Branch_1_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_1_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   0           Block35_1_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_1_Concatenate (Concaten (None, 17, 17, 96)   0           Block35_1_Branch_0_Conv2d_1x1_Act
                                                                 Block35_1_Branch_1_Conv2d_0b_3x3_
                                                                 Block35_1_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_1_Conv2d_1x1 (Conv2D)   (None, 17, 17, 256)  24832       Block35_1_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_21 (Lambda)              (None, 17, 17, 256)  0           Block35_1_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_21 (Add)                    (None, 17, 17, 256)  0           Conv2d_4b_3x3_Activation[0][0]   
                                                                 lambda_21[0][0]                  
__________________________________________________________________________________________________
Block35_1_Activation (Activatio (None, 17, 17, 256)  0           add_21[0][0]                     
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_1_Activation[0][0]       
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_2_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_2_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_1_Activation[0][0]       
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_2_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_2_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_2_Branch_2_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_2_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_2_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_2_Branch_0_Conv2d_1x1 ( (None, 17, 17, 32)   8192        Block35_1_Activation[0][0]       
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_2_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   9216        Block35_2_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_2_Branch_0_Conv2d_1x1_B (None, 17, 17, 32)   96          Block35_2_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_2_Branch_1_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   96          Block35_2_Branch_2_Conv2d_0c_3x3[
__________________________________________________________________________________________________
Block35_2_Branch_0_Conv2d_1x1_A (None, 17, 17, 32)   0           Block35_2_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block35_2_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_2_Branch_1_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_2_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   0           Block35_2_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_2_Concatenate (Concaten (None, 17, 17, 96)   0           Block35_2_Branch_0_Conv2d_1x1_Act
                                                                 Block35_2_Branch_1_Conv2d_0b_3x3_
                                                                 Block35_2_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_2_Conv2d_1x1 (Conv2D)   (None, 17, 17, 256)  24832       Block35_2_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_22 (Lambda)              (None, 17, 17, 256)  0           Block35_2_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_22 (Add)                    (None, 17, 17, 256)  0           Block35_1_Activation[0][0]       
                                                                 lambda_22[0][0]                  
__________________________________________________________________________________________________
Block35_2_Activation (Activatio (None, 17, 17, 256)  0           add_22[0][0]                     
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_2_Activation[0][0]       
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_3_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_3_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_2_Activation[0][0]       
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_3_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_3_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_3_Branch_2_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_3_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_3_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_3_Branch_0_Conv2d_1x1 ( (None, 17, 17, 32)   8192        Block35_2_Activation[0][0]       
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_3_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   9216        Block35_3_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_3_Branch_0_Conv2d_1x1_B (None, 17, 17, 32)   96          Block35_3_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_3_Branch_1_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   96          Block35_3_Branch_2_Conv2d_0c_3x3[
__________________________________________________________________________________________________
Block35_3_Branch_0_Conv2d_1x1_A (None, 17, 17, 32)   0           Block35_3_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block35_3_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_3_Branch_1_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_3_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   0           Block35_3_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_3_Concatenate (Concaten (None, 17, 17, 96)   0           Block35_3_Branch_0_Conv2d_1x1_Act
                                                                 Block35_3_Branch_1_Conv2d_0b_3x3_
                                                                 Block35_3_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_3_Conv2d_1x1 (Conv2D)   (None, 17, 17, 256)  24832       Block35_3_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_23 (Lambda)              (None, 17, 17, 256)  0           Block35_3_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_23 (Add)                    (None, 17, 17, 256)  0           Block35_2_Activation[0][0]       
                                                                 lambda_23[0][0]                  
__________________________________________________________________________________________________
Block35_3_Activation (Activatio (None, 17, 17, 256)  0           add_23[0][0]                     
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_3_Activation[0][0]       
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_4_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_4_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_3_Activation[0][0]       
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_4_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_4_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_4_Branch_2_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_4_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_4_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_4_Branch_0_Conv2d_1x1 ( (None, 17, 17, 32)   8192        Block35_3_Activation[0][0]       
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_4_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   9216        Block35_4_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_4_Branch_0_Conv2d_1x1_B (None, 17, 17, 32)   96          Block35_4_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_4_Branch_1_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   96          Block35_4_Branch_2_Conv2d_0c_3x3[
__________________________________________________________________________________________________
Block35_4_Branch_0_Conv2d_1x1_A (None, 17, 17, 32)   0           Block35_4_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block35_4_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_4_Branch_1_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_4_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   0           Block35_4_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_4_Concatenate (Concaten (None, 17, 17, 96)   0           Block35_4_Branch_0_Conv2d_1x1_Act
                                                                 Block35_4_Branch_1_Conv2d_0b_3x3_
                                                                 Block35_4_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_4_Conv2d_1x1 (Conv2D)   (None, 17, 17, 256)  24832       Block35_4_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_24 (Lambda)              (None, 17, 17, 256)  0           Block35_4_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_24 (Add)                    (None, 17, 17, 256)  0           Block35_3_Activation[0][0]       
                                                                 lambda_24[0][0]                  
__________________________________________________________________________________________________
Block35_4_Activation (Activatio (None, 17, 17, 256)  0           add_24[0][0]                     
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_4_Activation[0][0]       
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_5_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_5_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   8192        Block35_4_Activation[0][0]       
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_5_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   96          Block35_5_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_5_Branch_2_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0a_1x (None, 17, 17, 32)   0           Block35_5_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_5_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_5_Branch_0_Conv2d_1x1 ( (None, 17, 17, 32)   8192        Block35_4_Activation[0][0]       
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   9216        Block35_5_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   9216        Block35_5_Branch_2_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_5_Branch_0_Conv2d_1x1_B (None, 17, 17, 32)   96          Block35_5_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   96          Block35_5_Branch_1_Conv2d_0b_3x3[
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   96          Block35_5_Branch_2_Conv2d_0c_3x3[
__________________________________________________________________________________________________
Block35_5_Branch_0_Conv2d_1x1_A (None, 17, 17, 32)   0           Block35_5_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block35_5_Branch_1_Conv2d_0b_3x (None, 17, 17, 32)   0           Block35_5_Branch_1_Conv2d_0b_3x3_
__________________________________________________________________________________________________
Block35_5_Branch_2_Conv2d_0c_3x (None, 17, 17, 32)   0           Block35_5_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_5_Concatenate (Concaten (None, 17, 17, 96)   0           Block35_5_Branch_0_Conv2d_1x1_Act
                                                                 Block35_5_Branch_1_Conv2d_0b_3x3_
                                                                 Block35_5_Branch_2_Conv2d_0c_3x3_
__________________________________________________________________________________________________
Block35_5_Conv2d_1x1 (Conv2D)   (None, 17, 17, 256)  24832       Block35_5_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_25 (Lambda)              (None, 17, 17, 256)  0           Block35_5_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_25 (Add)                    (None, 17, 17, 256)  0           Block35_4_Activation[0][0]       
                                                                 lambda_25[0][0]                  
__________________________________________________________________________________________________
Block35_5_Activation (Activatio (None, 17, 17, 256)  0           add_25[0][0]                     
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0a_1x1 (None, 17, 17, 192)  49152       Block35_5_Activation[0][0]       
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0a_1x1 (None, 17, 17, 192)  576         Mixed_6a_Branch_1_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0a_1x1 (None, 17, 17, 192)  0           Mixed_6a_Branch_1_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0b_3x3 (None, 17, 17, 192)  331776      Mixed_6a_Branch_1_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0b_3x3 (None, 17, 17, 192)  576         Mixed_6a_Branch_1_Conv2d_0b_3x3[0
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_0b_3x3 (None, 17, 17, 192)  0           Mixed_6a_Branch_1_Conv2d_0b_3x3_B
__________________________________________________________________________________________________
Mixed_6a_Branch_0_Conv2d_1a_3x3 (None, 8, 8, 384)    884736      Block35_5_Activation[0][0]       
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_1a_3x3 (None, 8, 8, 256)    442368      Mixed_6a_Branch_1_Conv2d_0b_3x3_A
__________________________________________________________________________________________________
Mixed_6a_Branch_0_Conv2d_1a_3x3 (None, 8, 8, 384)    1152        Mixed_6a_Branch_0_Conv2d_1a_3x3[0
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_1a_3x3 (None, 8, 8, 256)    768         Mixed_6a_Branch_1_Conv2d_1a_3x3[0
__________________________________________________________________________________________________
Mixed_6a_Branch_0_Conv2d_1a_3x3 (None, 8, 8, 384)    0           Mixed_6a_Branch_0_Conv2d_1a_3x3_B
__________________________________________________________________________________________________
Mixed_6a_Branch_1_Conv2d_1a_3x3 (None, 8, 8, 256)    0           Mixed_6a_Branch_1_Conv2d_1a_3x3_B
__________________________________________________________________________________________________
Mixed_6a_Branch_2_MaxPool_1a_3x (None, 8, 8, 256)    0           Block35_5_Activation[0][0]       
__________________________________________________________________________________________________
Mixed_6a (Concatenate)          (None, 8, 8, 896)    0           Mixed_6a_Branch_0_Conv2d_1a_3x3_A
                                                                 Mixed_6a_Branch_1_Conv2d_1a_3x3_A
                                                                 Mixed_6a_Branch_2_MaxPool_1a_3x3[
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0a_1x (None, 8, 8, 128)    114688      Mixed_6a[0][0]                   
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_1_Branch_1_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_1_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_1_Branch_1_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_1_Branch_1_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_1_Branch_1_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_1_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Mixed_6a[0][0]                   
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_1_Branch_1_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_1_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_1_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_1_Branch_1_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_1_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_1_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_1_Branch_1_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_1_Branch_1_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_1_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_1_Branch_0_Conv2d_1x1_Act
                                                                 Block17_1_Branch_1_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_1_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_1_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_26 (Lambda)              (None, 8, 8, 896)    0           Block17_1_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_26 (Add)                    (None, 8, 8, 896)    0           Mixed_6a[0][0]                   
                                                                 lambda_26[0][0]                  
__________________________________________________________________________________________________
Block17_1_Activation (Activatio (None, 8, 8, 896)    0           add_26[0][0]                     
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_1_Activation[0][0]       
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_2_Branch_2_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_2_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_2_Branch_2_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_2_Branch_2_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_2_Branch_2_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_2_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_1_Activation[0][0]       
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_2_Branch_2_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_2_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_2_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_2_Branch_2_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_2_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_2_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_2_Branch_2_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_2_Branch_2_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_2_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_2_Branch_0_Conv2d_1x1_Act
                                                                 Block17_2_Branch_2_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_2_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_2_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_27 (Lambda)              (None, 8, 8, 896)    0           Block17_2_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_27 (Add)                    (None, 8, 8, 896)    0           Block17_1_Activation[0][0]       
                                                                 lambda_27[0][0]                  
__________________________________________________________________________________________________
Block17_2_Activation (Activatio (None, 8, 8, 896)    0           add_27[0][0]                     
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_2_Activation[0][0]       
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_3_Branch_3_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_3_Branch_3_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_3_Branch_3_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_3_Branch_3_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_3_Branch_3_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_3_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_2_Activation[0][0]       
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_3_Branch_3_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_3_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_3_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_3_Branch_3_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_3_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_3_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_3_Branch_3_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_3_Branch_3_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_3_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_3_Branch_0_Conv2d_1x1_Act
                                                                 Block17_3_Branch_3_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_3_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_3_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_28 (Lambda)              (None, 8, 8, 896)    0           Block17_3_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_28 (Add)                    (None, 8, 8, 896)    0           Block17_2_Activation[0][0]       
                                                                 lambda_28[0][0]                  
__________________________________________________________________________________________________
Block17_3_Activation (Activatio (None, 8, 8, 896)    0           add_28[0][0]                     
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_3_Activation[0][0]       
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_4_Branch_4_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_4_Branch_4_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_4_Branch_4_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_4_Branch_4_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_4_Branch_4_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_4_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_3_Activation[0][0]       
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_4_Branch_4_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_4_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_4_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_4_Branch_4_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_4_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_4_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_4_Branch_4_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_4_Branch_4_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_4_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_4_Branch_0_Conv2d_1x1_Act
                                                                 Block17_4_Branch_4_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_4_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_4_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_29 (Lambda)              (None, 8, 8, 896)    0           Block17_4_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_29 (Add)                    (None, 8, 8, 896)    0           Block17_3_Activation[0][0]       
                                                                 lambda_29[0][0]                  
__________________________________________________________________________________________________
Block17_4_Activation (Activatio (None, 8, 8, 896)    0           add_29[0][0]                     
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_4_Activation[0][0]       
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_5_Branch_5_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_5_Branch_5_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_5_Branch_5_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_5_Branch_5_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_5_Branch_5_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_5_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_4_Activation[0][0]       
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_5_Branch_5_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_5_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_5_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_5_Branch_5_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_5_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_5_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_5_Branch_5_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_5_Branch_5_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_5_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_5_Branch_0_Conv2d_1x1_Act
                                                                 Block17_5_Branch_5_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_5_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_5_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_30 (Lambda)              (None, 8, 8, 896)    0           Block17_5_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_30 (Add)                    (None, 8, 8, 896)    0           Block17_4_Activation[0][0]       
                                                                 lambda_30[0][0]                  
__________________________________________________________________________________________________
Block17_5_Activation (Activatio (None, 8, 8, 896)    0           add_30[0][0]                     
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_5_Activation[0][0]       
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_6_Branch_6_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_6_Branch_6_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_6_Branch_6_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_6_Branch_6_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_6_Branch_6_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_6_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_5_Activation[0][0]       
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_6_Branch_6_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_6_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_6_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_6_Branch_6_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_6_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_6_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_6_Branch_6_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_6_Branch_6_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_6_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_6_Branch_0_Conv2d_1x1_Act
                                                                 Block17_6_Branch_6_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_6_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_6_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_31 (Lambda)              (None, 8, 8, 896)    0           Block17_6_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_31 (Add)                    (None, 8, 8, 896)    0           Block17_5_Activation[0][0]       
                                                                 lambda_31[0][0]                  
__________________________________________________________________________________________________
Block17_6_Activation (Activatio (None, 8, 8, 896)    0           add_31[0][0]                     
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_6_Activation[0][0]       
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_7_Branch_7_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_7_Branch_7_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_7_Branch_7_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_7_Branch_7_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_7_Branch_7_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_7_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_6_Activation[0][0]       
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_7_Branch_7_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_7_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_7_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_7_Branch_7_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_7_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_7_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_7_Branch_7_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_7_Branch_7_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_7_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_7_Branch_0_Conv2d_1x1_Act
                                                                 Block17_7_Branch_7_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_7_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_7_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_32 (Lambda)              (None, 8, 8, 896)    0           Block17_7_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_32 (Add)                    (None, 8, 8, 896)    0           Block17_6_Activation[0][0]       
                                                                 lambda_32[0][0]                  
__________________________________________________________________________________________________
Block17_7_Activation (Activatio (None, 8, 8, 896)    0           add_32[0][0]                     
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_7_Activation[0][0]       
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_8_Branch_8_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_8_Branch_8_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_8_Branch_8_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_8_Branch_8_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_8_Branch_8_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_8_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_7_Activation[0][0]       
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_8_Branch_8_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_8_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_8_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_8_Branch_8_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_8_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_8_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_8_Branch_8_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_8_Branch_8_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_8_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_8_Branch_0_Conv2d_1x1_Act
                                                                 Block17_8_Branch_8_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_8_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_8_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_33 (Lambda)              (None, 8, 8, 896)    0           Block17_8_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_33 (Add)                    (None, 8, 8, 896)    0           Block17_7_Activation[0][0]       
                                                                 lambda_33[0][0]                  
__________________________________________________________________________________________________
Block17_8_Activation (Activatio (None, 8, 8, 896)    0           add_33[0][0]                     
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0a_1x (None, 8, 8, 128)    114688      Block17_8_Activation[0][0]       
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0a_1x (None, 8, 8, 128)    384         Block17_9_Branch_9_Conv2d_0a_1x1[
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0a_1x (None, 8, 8, 128)    0           Block17_9_Branch_9_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0b_1x (None, 8, 8, 128)    114688      Block17_9_Branch_9_Conv2d_0a_1x1_
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0b_1x (None, 8, 8, 128)    384         Block17_9_Branch_9_Conv2d_0b_1x7[
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0b_1x (None, 8, 8, 128)    0           Block17_9_Branch_9_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_9_Branch_0_Conv2d_1x1 ( (None, 8, 8, 128)    114688      Block17_8_Activation[0][0]       
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0c_7x (None, 8, 8, 128)    114688      Block17_9_Branch_9_Conv2d_0b_1x7_
__________________________________________________________________________________________________
Block17_9_Branch_0_Conv2d_1x1_B (None, 8, 8, 128)    384         Block17_9_Branch_0_Conv2d_1x1[0][
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0c_7x (None, 8, 8, 128)    384         Block17_9_Branch_9_Conv2d_0c_7x1[
__________________________________________________________________________________________________
Block17_9_Branch_0_Conv2d_1x1_A (None, 8, 8, 128)    0           Block17_9_Branch_0_Conv2d_1x1_Bat
__________________________________________________________________________________________________
Block17_9_Branch_9_Conv2d_0c_7x (None, 8, 8, 128)    0           Block17_9_Branch_9_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_9_Concatenate (Concaten (None, 8, 8, 256)    0           Block17_9_Branch_0_Conv2d_1x1_Act
                                                                 Block17_9_Branch_9_Conv2d_0c_7x1_
__________________________________________________________________________________________________
Block17_9_Conv2d_1x1 (Conv2D)   (None, 8, 8, 896)    230272      Block17_9_Concatenate[0][0]      
__________________________________________________________________________________________________
lambda_34 (Lambda)              (None, 8, 8, 896)    0           Block17_9_Conv2d_1x1[0][0]       
__________________________________________________________________________________________________
add_34 (Add)                    (None, 8, 8, 896)    0           Block17_8_Activation[0][0]       
                                                                 lambda_34[0][0]                  
__________________________________________________________________________________________________
Block17_9_Activation (Activatio (None, 8, 8, 896)    0           add_34[0][0]                     
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0a_ (None, 8, 8, 128)    114688      Block17_9_Activation[0][0]       
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0a_ (None, 8, 8, 128)    384         Block17_10_Branch_10_Conv2d_0a_1x
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0a_ (None, 8, 8, 128)    0           Block17_10_Branch_10_Conv2d_0a_1x
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0b_ (None, 8, 8, 128)    114688      Block17_10_Branch_10_Conv2d_0a_1x
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0b_ (None, 8, 8, 128)    384         Block17_10_Branch_10_Conv2d_0b_1x
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0b_ (None, 8, 8, 128)    0           Block17_10_Branch_10_Conv2d_0b_1x
__________________________________________________________________________________________________
Block17_10_Branch_0_Conv2d_1x1  (None, 8, 8, 128)    114688      Block17_9_Activation[0][0]       
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0c_ (None, 8, 8, 128)    114688      Block17_10_Branch_10_Conv2d_0b_1x
__________________________________________________________________________________________________
Block17_10_Branch_0_Conv2d_1x1_ (None, 8, 8, 128)    384         Block17_10_Branch_0_Conv2d_1x1[0]
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0c_ (None, 8, 8, 128)    384         Block17_10_Branch_10_Conv2d_0c_7x
__________________________________________________________________________________________________
Block17_10_Branch_0_Conv2d_1x1_ (None, 8, 8, 128)    0           Block17_10_Branch_0_Conv2d_1x1_Ba
__________________________________________________________________________________________________
Block17_10_Branch_10_Conv2d_0c_ (None, 8, 8, 128)    0           Block17_10_Branch_10_Conv2d_0c_7x
__________________________________________________________________________________________________
Block17_10_Concatenate (Concate (None, 8, 8, 256)    0           Block17_10_Branch_0_Conv2d_1x1_Ac
                                                                 Block17_10_Branch_10_Conv2d_0c_7x
__________________________________________________________________________________________________
Block17_10_Conv2d_1x1 (Conv2D)  (None, 8, 8, 896)    230272      Block17_10_Concatenate[0][0]     
__________________________________________________________________________________________________
lambda_35 (Lambda)              (None, 8, 8, 896)    0           Block17_10_Conv2d_1x1[0][0]      
__________________________________________________________________________________________________
add_35 (Add)                    (None, 8, 8, 896)    0           Block17_9_Activation[0][0]       
                                                                 lambda_35[0][0]                  
__________________________________________________________________________________________________
Block17_10_Activation (Activati (None, 8, 8, 896)    0           add_35[0][0]                     
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0a_1x1 (None, 8, 8, 256)    229376      Block17_10_Activation[0][0]      
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0a_1x1 (None, 8, 8, 256)    768         Mixed_7a_Branch_2_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0a_1x1 (None, 8, 8, 256)    0           Mixed_7a_Branch_2_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_0a_1x1 (None, 8, 8, 256)    229376      Block17_10_Activation[0][0]      
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_0a_1x1 (None, 8, 8, 256)    229376      Block17_10_Activation[0][0]      
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0b_3x3 (None, 8, 8, 256)    589824      Mixed_7a_Branch_2_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_0a_1x1 (None, 8, 8, 256)    768         Mixed_7a_Branch_0_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_0a_1x1 (None, 8, 8, 256)    768         Mixed_7a_Branch_1_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0b_3x3 (None, 8, 8, 256)    768         Mixed_7a_Branch_2_Conv2d_0b_3x3[0
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_0a_1x1 (None, 8, 8, 256)    0           Mixed_7a_Branch_0_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_0a_1x1 (None, 8, 8, 256)    0           Mixed_7a_Branch_1_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_0b_3x3 (None, 8, 8, 256)    0           Mixed_7a_Branch_2_Conv2d_0b_3x3_B
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_1a_3x3 (None, 3, 3, 384)    884736      Mixed_7a_Branch_0_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_1a_3x3 (None, 3, 3, 256)    589824      Mixed_7a_Branch_1_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_1a_3x3 (None, 3, 3, 256)    589824      Mixed_7a_Branch_2_Conv2d_0b_3x3_A
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_1a_3x3 (None, 3, 3, 384)    1152        Mixed_7a_Branch_0_Conv2d_1a_3x3[0
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_1a_3x3 (None, 3, 3, 256)    768         Mixed_7a_Branch_1_Conv2d_1a_3x3[0
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_1a_3x3 (None, 3, 3, 256)    768         Mixed_7a_Branch_2_Conv2d_1a_3x3[0
__________________________________________________________________________________________________
Mixed_7a_Branch_0_Conv2d_1a_3x3 (None, 3, 3, 384)    0           Mixed_7a_Branch_0_Conv2d_1a_3x3_B
__________________________________________________________________________________________________
Mixed_7a_Branch_1_Conv2d_1a_3x3 (None, 3, 3, 256)    0           Mixed_7a_Branch_1_Conv2d_1a_3x3_B
__________________________________________________________________________________________________
Mixed_7a_Branch_2_Conv2d_1a_3x3 (None, 3, 3, 256)    0           Mixed_7a_Branch_2_Conv2d_1a_3x3_B
__________________________________________________________________________________________________
Mixed_7a_Branch_3_MaxPool_1a_3x (None, 3, 3, 896)    0           Block17_10_Activation[0][0]      
__________________________________________________________________________________________________
Mixed_7a (Concatenate)          (None, 3, 3, 1792)   0           Mixed_7a_Branch_0_Conv2d_1a_3x3_A
                                                                 Mixed_7a_Branch_1_Conv2d_1a_3x3_A
                                                                 Mixed_7a_Branch_2_Conv2d_1a_3x3_A
                                                                 Mixed_7a_Branch_3_MaxPool_1a_3x3[
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Mixed_7a[0][0]                   
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_1_Branch_1_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_1_Branch_1_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_1_Branch_1_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_1_Branch_1_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_1_Branch_1_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_1_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Mixed_7a[0][0]                   
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_1_Branch_1_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_1_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_1_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_1_Branch_1_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_1_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_1_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_1_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_1_Branch_1_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_1_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_1_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_1_Branch_1_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_1_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_1_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_36 (Lambda)              (None, 3, 3, 1792)   0           Block8_1_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_36 (Add)                    (None, 3, 3, 1792)   0           Mixed_7a[0][0]                   
                                                                 lambda_36[0][0]                  
__________________________________________________________________________________________________
Block8_1_Activation (Activation (None, 3, 3, 1792)   0           add_36[0][0]                     
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Block8_1_Activation[0][0]        
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_2_Branch_2_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_2_Branch_2_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_2_Branch_2_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_2_Branch_2_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_2_Branch_2_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_2_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Block8_1_Activation[0][0]        
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_2_Branch_2_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_2_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_2_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_2_Branch_2_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_2_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_2_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_2_Branch_2_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_2_Branch_2_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_2_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_2_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_2_Branch_2_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_2_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_2_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_37 (Lambda)              (None, 3, 3, 1792)   0           Block8_2_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_37 (Add)                    (None, 3, 3, 1792)   0           Block8_1_Activation[0][0]        
                                                                 lambda_37[0][0]                  
__________________________________________________________________________________________________
Block8_2_Activation (Activation (None, 3, 3, 1792)   0           add_37[0][0]                     
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Block8_2_Activation[0][0]        
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_3_Branch_3_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_3_Branch_3_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_3_Branch_3_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_3_Branch_3_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_3_Branch_3_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_3_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Block8_2_Activation[0][0]        
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_3_Branch_3_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_3_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_3_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_3_Branch_3_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_3_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_3_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_3_Branch_3_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_3_Branch_3_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_3_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_3_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_3_Branch_3_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_3_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_3_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_38 (Lambda)              (None, 3, 3, 1792)   0           Block8_3_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_38 (Add)                    (None, 3, 3, 1792)   0           Block8_2_Activation[0][0]        
                                                                 lambda_38[0][0]                  
__________________________________________________________________________________________________
Block8_3_Activation (Activation (None, 3, 3, 1792)   0           add_38[0][0]                     
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Block8_3_Activation[0][0]        
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_4_Branch_4_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_4_Branch_4_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_4_Branch_4_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_4_Branch_4_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_4_Branch_4_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_4_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Block8_3_Activation[0][0]        
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_4_Branch_4_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_4_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_4_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_4_Branch_4_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_4_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_4_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_4_Branch_4_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_4_Branch_4_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_4_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_4_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_4_Branch_4_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_4_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_4_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_39 (Lambda)              (None, 3, 3, 1792)   0           Block8_4_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_39 (Add)                    (None, 3, 3, 1792)   0           Block8_3_Activation[0][0]        
                                                                 lambda_39[0][0]                  
__________________________________________________________________________________________________
Block8_4_Activation (Activation (None, 3, 3, 1792)   0           add_39[0][0]                     
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Block8_4_Activation[0][0]        
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_5_Branch_5_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_5_Branch_5_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_5_Branch_5_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_5_Branch_5_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_5_Branch_5_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_5_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Block8_4_Activation[0][0]        
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_5_Branch_5_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_5_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_5_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_5_Branch_5_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_5_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_5_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_5_Branch_5_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_5_Branch_5_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_5_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_5_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_5_Branch_5_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_5_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_5_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_40 (Lambda)              (None, 3, 3, 1792)   0           Block8_5_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_40 (Add)                    (None, 3, 3, 1792)   0           Block8_4_Activation[0][0]        
                                                                 lambda_40[0][0]                  
__________________________________________________________________________________________________
Block8_5_Activation (Activation (None, 3, 3, 1792)   0           add_40[0][0]                     
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    344064      Block8_5_Activation[0][0]        
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    576         Block8_6_Branch_1_Conv2d_0a_1x1[0
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0a_1x1 (None, 3, 3, 192)    0           Block8_6_Branch_1_Conv2d_0a_1x1_B
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    110592      Block8_6_Branch_1_Conv2d_0a_1x1_A
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    576         Block8_6_Branch_1_Conv2d_0b_1x3[0
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0b_1x3 (None, 3, 3, 192)    0           Block8_6_Branch_1_Conv2d_0b_1x3_B
__________________________________________________________________________________________________
Block8_6_Branch_0_Conv2d_1x1 (C (None, 3, 3, 192)    344064      Block8_5_Activation[0][0]        
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    110592      Block8_6_Branch_1_Conv2d_0b_1x3_A
__________________________________________________________________________________________________
Block8_6_Branch_0_Conv2d_1x1_Ba (None, 3, 3, 192)    576         Block8_6_Branch_0_Conv2d_1x1[0][0
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    576         Block8_6_Branch_1_Conv2d_0c_3x1[0
__________________________________________________________________________________________________
Block8_6_Branch_0_Conv2d_1x1_Ac (None, 3, 3, 192)    0           Block8_6_Branch_0_Conv2d_1x1_Batc
__________________________________________________________________________________________________
Block8_6_Branch_1_Conv2d_0c_3x1 (None, 3, 3, 192)    0           Block8_6_Branch_1_Conv2d_0c_3x1_B
__________________________________________________________________________________________________
Block8_6_Concatenate (Concatena (None, 3, 3, 384)    0           Block8_6_Branch_0_Conv2d_1x1_Acti
                                                                 Block8_6_Branch_1_Conv2d_0c_3x1_A
__________________________________________________________________________________________________
Block8_6_Conv2d_1x1 (Conv2D)    (None, 3, 3, 1792)   689920      Block8_6_Concatenate[0][0]       
__________________________________________________________________________________________________
lambda_41 (Lambda)              (None, 3, 3, 1792)   0           Block8_6_Conv2d_1x1[0][0]        
__________________________________________________________________________________________________
add_41 (Add)                    (None, 3, 3, 1792)   0           Block8_5_Activation[0][0]        
                                                                 lambda_41[0][0]                  
__________________________________________________________________________________________________
AvgPool (GlobalAveragePooling2D (None, 1792)         0           add_41[0][0]                     
__________________________________________________________________________________________________
Dropout (Dropout)               (None, 1792)         0           AvgPool[0][0]                    
__________________________________________________________________________________________________
Bottleneck (Dense)              (None, 128)          229376      Dropout[0][0]                    
__________________________________________________________________________________________________
Bottleneck_BatchNorm (BatchNorm (None, 128)          384         Bottleneck[0][0]                 
==================================================================================================
Total params: 22,808,144
Trainable params: 22,779,312
Non-trainable params: 28,832
__________________________________________________________________________________________________

Detect faces in the training-, validation- and test-images

For training and test the 5 Celebrities Dataset is applied. Download this dataset from Kaggle. The dataset contains images of 5 celebrities, subdivided into a training-, validation and test-partition. If you inspect the images you will realize, that the images do not only contain the face of the persons. Therefore, we first have to crop the faces from the entire images as described in notebook faceDetection.ipynb. We reimplement the corresponding method extract_face() from there.

#!pip install mtcnn
import os
import logging
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  # FATAL
logging.getLogger('tensorflow').setLevel(logging.FATAL)
from os import listdir
from os.path import isdir
from PIL import Image
from numpy import asarray
from numpy import savez_compressed,load, expand_dims
from matplotlib import pyplot
from mtcnn.mtcnn import MTCNN
# extract a single face from a given photograph
def extract_face(filename, required_size=(160, 160)):
    image = Image.open(filename)
    # convert to RGB, if needed
    image = image.convert('RGB')
    # convert to array
    pixels = asarray(image)
    # create the detector, using default weights
    detector = MTCNN()
    # detect faces in the image
    results = detector.detect_faces(pixels)
    # extract the bounding box from the first face
    x1, y1, width, height = results[0]['box']
    # bug fix
    x1, y1 = abs(x1), abs(y1)
    x2, y2 = x1 + width, y1 + height
    # extract the face
    face = pixels[y1:y2, x1:x2]
    # resize pixels to the model size
    image = Image.fromarray(face)
    image = image.resize(required_size)
    face_array = asarray(image)
    return face_array
# specify folder to plot
#datafolder='/Users/maucher/gitprojects/or/nb/Data/5celebritiesDataset'
datafolder='/Users/johannes/gitprojects/or/nb/Data/5celebritiesDataset'
folder = datafolder+'/train/ben_afflek/'
i = 1
# enumerate files
for filename in listdir(folder):
    # path
    path = folder + filename
    # get face
    face = extract_face(path)
    print(i, face.shape)
    # plot
    pyplot.subplot(2, 7, i)
    pyplot.axis('off')
    pyplot.imshow(face)
    i += 1
pyplot.show()
1 (160, 160, 3)
2 (160, 160, 3)
3 (160, 160, 3)
4 (160, 160, 3)
5 (160, 160, 3)
6 (160, 160, 3)
7 (160, 160, 3)
8 (160, 160, 3)
9 (160, 160, 3)
10 (160, 160, 3)
11 (160, 160, 3)
12 (160, 160, 3)
13 (160, 160, 3)
14 (160, 160, 3)
../_images/faceRecognition_14_1.png

The function load_faces(directory) applies the extract_face()-method to all images in directory and returns a list of cropped faces.

def load_faces(directory):
    faces = list()
    # enumerate files
    for filename in listdir(directory):
        # path
        path = directory + filename
        # get face
        face = extract_face(path)
        # store
        faces.append(face)
    return faces

The function load_dataset(directory) scans all subdirectories of directory. For each subdirectory it invokes the load_faces()-function which returns a list of all cropped faces of the person whose images are saved in the subdirectory. As can be seen below the call of load_dataset("train") returns all faces and their corresponding labels used for training and load_dataset("val") returns all faces and their corresponding labels used for validation.

def load_dataset(directory):
    X, y = list(), list()
    # enumerate folders, on per class
    for subdir in listdir(directory):
        # path
        path = directory + subdir + '/'
        # skip any files that might be in the dir
        if not isdir(path):
            continue
        # load all faces in the subdirectory
        faces = load_faces(path)
        # create labels
        labels = [subdir for _ in range(len(faces))]
        # summarize progress
        print('>loaded %d examples for class: %s' % (len(faces), subdir))
        # store
        X.extend(faces)
        y.extend(labels)
    return asarray(X), asarray(y)
trainX, trainy = load_dataset(datafolder+'/train/')
print(trainX.shape, trainy.shape)
# load test dataset
testX, testy = load_dataset(datafolder+'/val/')
print(testX.shape, testy.shape)
# save arrays to one file in compressed format
>loaded 14 examples for class: ben_afflek
>loaded 19 examples for class: madonna
>loaded 17 examples for class: elton_john
>loaded 22 examples for class: mindy_kaling
>loaded 21 examples for class: jerry_seinfeld
(93, 160, 160, 3) (93,)
>loaded 5 examples for class: ben_afflek
>loaded 5 examples for class: madonna
>loaded 5 examples for class: elton_john
>loaded 5 examples for class: mindy_kaling
>loaded 5 examples for class: jerry_seinfeld
(25, 160, 160, 3) (25,)
savez_compressed('5celebritiesDataset.npz', trainX, trainy, testX, testy)

Calculate FaceNet-embeddings

data = load('5celebritiesDataset.npz')
trainX, trainy, testX, testy = data['arr_0'], data['arr_1'], data['arr_2'], data['arr_3']
print('Loaded: ', trainX.shape, trainy.shape, testX.shape, testy.shape)
Loaded:  (93, 160, 160, 3) (93,) (25, 160, 160, 3) (25,)

Within the following function get_embedding(model,face_pixels) the pretrained FaceNet model is applied to calculate for the passed face the corresponding face-embedding, which is a vector of length 128. Before passing the face image to the model it must be standardized.

def get_embedding(model, face_pixels):
    # scale pixel values
    face_pixels = face_pixels.astype('float32')
    # standardize pixel values across channels (global)
    mean, std = face_pixels.mean(), face_pixels.std()
    face_pixels = (face_pixels - mean) / std
    # transform face into one sample
    samples = expand_dims(face_pixels, axis=0)
    # make prediction to get embedding
    yhat = model.predict(samples)
    return yhat[0]
# load the face dataset
data = load("5celebritiesDataset.npz")
trainX, trainy, testX, testy = data['arr_0'], data['arr_1'], data['arr_2'], data['arr_3']
print('Loaded: ', trainX.shape, trainy.shape, testX.shape, testy.shape)
Loaded:  (93, 160, 160, 3) (93,) (25, 160, 160, 3) (25,)

In the next code-cell each face in the training-set is converted to its face-embedding:

newTrainX = list()
for face_pixels in trainX:
    embedding = get_embedding(model, face_pixels)
    newTrainX.append(embedding)
newTrainX = asarray(newTrainX)
print(newTrainX.shape)
(93, 128)

Then, also for the face-images in the validation dataset the corresponding face-embeddings are calculated.

newTestX = list()
for face_pixels in testX:
    embedding = get_embedding(model, face_pixels)
    newTestX.append(embedding)
newTestX = asarray(newTestX)
print(newTestX.shape)
(25, 128)

Finally, the train- and test-embeddings an the corresponding labels are saved persistently:

savez_compressed('5celebritiesEmbeddings.npz', newTrainX, trainy, newTestX, testy)

Apply FaceNet Embeddings to train a SVM classifier

from sklearn.metrics import accuracy_score
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import Normalizer
from sklearn.svm import SVC
from random import choice
from matplotlib import pyplot
data = load('5celebritiesDataset.npz')
testX_faces = data['arr_2']
# load face embeddings
data = load('5celebritiesEmbeddings.npz')

Preprocessing

trainX, trainy, testX, testy = data['arr_0'], data['arr_1'], data['arr_2'], data['arr_3']
print('Dataset: train=%d, test=%d' % (trainX.shape[0], testX.shape[0]))
# normalize input vectors
in_encoder = Normalizer(norm='l2')
trainX = in_encoder.transform(trainX)
testX = in_encoder.transform(testX)
# label encode targets
out_encoder = LabelEncoder()
out_encoder.fit(trainy)
trainy = out_encoder.transform(trainy)
testy = out_encoder.transform(testy)
Dataset: train=93, test=25

Training

# fit model
model = SVC(kernel='linear', probability=True)
model.fit(trainX, trainy)
SVC(kernel='linear', probability=True)

Validation

# predict
yhat_train = model.predict(trainX)
yhat_test = model.predict(testX)
# score
score_train = accuracy_score(trainy, yhat_train)
score_test = accuracy_score(testy, yhat_test)
# summarize
print('Accuracy: train=%.3f, test=%.3f' % (score_train*100, score_test*100))
Accuracy: train=100.000, test=100.000
# test model on a random example from the test dataset
selection = choice([i for i in range(testX.shape[0])])
random_face_pixels = testX_faces[selection]
random_face_emb = testX[selection]
random_face_class = testy[selection]
random_face_name = out_encoder.inverse_transform([random_face_class])
# prediction for the face
samples = expand_dims(random_face_emb, axis=0)
yhat_class = model.predict(samples)
yhat_prob = model.predict_proba(samples)
# get name
class_index = yhat_class[0]
class_probability = yhat_prob[0,class_index] * 100
predict_names = out_encoder.inverse_transform(yhat_class)
print('Predicted: %s (%.3f)' % (predict_names[0], class_probability))
print('Expected: %s' % random_face_name[0])
# plot for fun
pyplot.imshow(random_face_pixels)
title = '%s (%.3f)' % (predict_names[0], class_probability)
pyplot.title(title)
pyplot.show()
Predicted: elton_john (91.049)
Expected: elton_john
../_images/faceRecognition_41_1.png