Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: Importing a SavedModel with tf.saved_model.load requires a 'tags=' argument

I'm following tutorial Hub with Keras with tensorflow 1.14. I didn't pip install tf-nightly-gpu as it does not seem to be available for MacOS. All went ok though until the keras.Sequential() :

import tensorflow_hub as hub
from tensorflow.keras import layers
classifier_url ="https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3"
IMAGE_SHAPE = (224, 224)
classifier = tf.keras.Sequential([
     hub.KerasLayer(classifier_url, input_shape=IMAGE_SHAPE+(3,))
])

Last line gives following error:

ValueError: Importing a SavedModel with tf.saved_model.load requires a 'tags=' argument if there is more than one MetaGraph. Got 'tags=None', but there are 2 MetaGraphs in the SavedModel with tag sets [[], ['train']]. Pass a 'tags=' argument to load this SavedModel.

Is it related to the tensorflow version or is it related to something else?

MacOS High Sierra 10.13.1 python 3.6.8 tensorflow 1.14.0

like image 255
Patrick Avatar asked Oct 15 '22 12:10

Patrick


1 Answers

This worked for me in TF 1.14.0:


# Image information
HEIGHT = 224
WIDTH = 224
CHANNELS = 3
IMAGE_SHAPE = (HEIGHT, WIDTH)

feature_extractor_url = "https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3" #@param {type:"string"}

module = hub.Module(feature_extractor_url, tags=['train'])
feature_extractor_layer = hub.KerasLayer(module, 
                                         input_shape=(HEIGHT, WIDTH, CHANNELS))

like image 191
gogasca Avatar answered Oct 21 '22 05:10

gogasca