nyoki-mtl / keras-facenet

Facenet implementation by Keras2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in inception_resnet_v1.py

KiraMichiru opened this issue · comments

As loading the provided file does not work with a different Python version, I tried to convert the weights from David Sandberg's pre-trained model via the provided code. The resulting embeddings were arbitrary, as already mentioned in one of the other comments. I tracked the issue down to a bug in the inception_resnet_v1.py code, line 102:

x = Lambda(scaling,
output_shape=K.int_shape(up)[1:],
arguments={'scale': scale})(up)

should actually say

up = Lambda(scaling,
output_shape=K.int_shape(up)[1:],
arguments={'scale': scale})(up)

as x is the input to the block that needs to go into the final addition with the scaled result computed in the block. However, with the current state of the code, x will be overwritten and the output of the block will be a scaled version of the result computed in the block.

Adding this change enabled me to export a model that gives me the same embeddings as David Sandberg's model.

Best,
Kira

@KiraMichiru
Thank you for reporting!
As you said there was a bug in inception_resnet_v1.py.
I fixed it.