Facenet: Pre-trained model returns 512 vector, I need 128

Created on 16 Jan 2020  路  8Comments  路  Source: davidsandberg/facenet

Hello everybody,

I'm using either 20180408-102900 or 20180402-114759 for .pb pre-trained model in a very small set of images. It works well using classify.py (I'm only interested in the embedding). However, I really need the 128 element vector, since the final dataset will contain 10*10^3 images.

How can I make the embedding coming from the LFW-trained-model return such a vector?

Really need this help.

Most helpful comment

I would agree with @ryecomp here. As long as reducing dims doesn't affect performance. @nora-illanes siamese nets can be trained with a triplet loss to reference euclidean distance later or softmax activation in the attempt of classification.

All 8 comments

Why do you feel like you need to reduce dimensions? I would recommend you just use the full 512 vector. I recently trained on the full 3.3 million images from vggface2 and it went okay. There shouldn't be any reason why you want to reduce these from a classification perspective. Of course you might run out of RAM while loading all the data, so you should batch data during training using a neural network like a simple hidden layer into softmax using fit_generator from keras or something.

If you want to try it, just perform PCA:

https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html

This will usually create more general vectors and you will probably lose a lot of accuracy I would guess. Unless you are looking for features that measure similarity then this would be a good idea.

Why do you feel like you .....There shouldn't be any reason why you want to reduce these from a classification perspective.

I need to create a library of embedding vectors to save it to a gigantic file.

If you want to try it, just perform PCA:
.... Unless you are looking for features that measure similarity then this would be a good idea.

Hmmm, I am looking for features of similarities. Thank you for your reply. The numbers in the vector are of huge dimensions, but I guess it is like that.

Thank you again!

How about training to get your own model ?
you can specify --embedding=128 when calling train_*.py script

Thanks for your reply!

How about training to get your own model ?
you can specify --embedding=128 when calling train_*.py script

I will try this. Why are you running train_? I have only one script from facenet repository, and that is train.py.

you can find train_tripletloss and train_softmax in src folder

Maybe you can apply PCA to 512-d vectors and reduce them to 128-d.

I would agree with @ryecomp here. As long as reducing dims doesn't affect performance. @nora-illanes siamese nets can be trained with a triplet loss to reference euclidean distance later or softmax activation in the attempt of classification.

Hello, Have you managed to turn 512 dimensions into 128 dimensions锛烪ow do you do?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Feynman27 picture Feynman27  路  3Comments

MaartenBloemen picture MaartenBloemen  路  3Comments

Zumbalamambo picture Zumbalamambo  路  3Comments

haochange picture haochange  路  3Comments

patienceFromZhou picture patienceFromZhou  路  3Comments