classification_models icon indicating copy to clipboard operation
classification_models copied to clipboard

ResNet18 with no top: How to obtain 512-dimensional vector?

Open andrei-volkau opened this issue 3 years ago • 1 comments

I am wondering how to obtain a 512-dimensional vector for an image. I am interested in ResNet18 with no top layer.

As for now, I am getting a list of vectors like the following one. list_of_vectors.txt

I expected getting one 512-dimensional vector for an image

andrei-volkau avatar Dec 14 '21 09:12 andrei-volkau

This might be late, but can be of use for anyone faced this

ResNet18, preprocess_input = Classifiers.get('resnet18')
base_model = ResNet18(input_shape=(224,224,3), weights='imagenet', include_top=False)
output = keras.layers.GlobalAveragePooling2D()(base_model.output)
resnet18 = keras.models.Model(inputs=[base_model.input], outputs=[output])

And by the way adding a list of vectors text file like that doesn't make any sense, you could have just shared the shape of your output.

Marwen-Bhj avatar Jan 20 '22 01:01 Marwen-Bhj