Image to dense vector embedding. This library uses the ResNet50 model in TensorFlow Keras, pre-trained on Imagenet, to generate image embeddings via https://keras.io/getting-started/faq/#how-can-i-obtain-the-output-of-an-intermediate-layer. Basically a clone of https://github.com/christiansafka/img2vec for TensorFlow Keras users.
img2vec_keras
uses the keras
module shipped with tensorflow
. To install img2vec_keras
and its dependencies
pip install git+git://github.com/jaredwinick/img2vec-keras.git
from img2vec_keras import Img2Vec
img2vec = Img2Vec()
x = img2vec.get_vec('/path/to/image/dog1.jpg')
Basic example with cosine similarity of vectors
Colab notebook using t-SNE to visualize image vectors
- Thanks to @gmgeorg for upgrading to TensorFlow 2.0