admin管理员组

文章数量:1397102

I have questions about a model obtained from TensorFlow Hub.

I am trying to use "movenet" with the following source code.

(1) The Input Shape of this model is (1, None, None, 3), but how can I fix the None part? To create a fixed TensorFlow Lite model, I want to fix the input shape to (1, 256, 256, 3).

(2) Also, I can't display the summary of this model. What should I do?

(3) I want to check the input shape and output shape after tf.saved_model.load, but when I run loaded.signatures['serving_default'], a KeyError occurs. How can I check the input shape and output shape after loading?

    input_size = 256

    model_url = ";
    model = tfhub.load(model_url)
    movenet = model.signatures['serving_default']
    print(movenet.structured_input_signature)
    print(movenet.structured_outputs)
    tf.saved_model.save(model, './saved_model')

    model.summary() # -->> ERROR

    loaded = tf.saved_model.load('./saved_model')
    print(list(loaded.signatures.keys())) # -->> [] # empty!
    movenet = loaded.signatures['serving_default'] # -->> ERROR
    print(movenet.structured_input_signature)
    print(movenet.structured_outputs)
((), {'input': TensorSpec(shape=(1, None, None, 3), dtype=tf.int32, name='input')})
{'output_0': TensorSpec(shape=(1, 6, 56), dtype=tf.float32, name='output_0')}
### model.summary() # -->> ERROR
'_UserObject' object has no attribute 'summary'
  File "/home/debian/sandbox/movenet/python/movenet_multi.py", line 126, in main
    model.summary() # -->> ERROR
  File "/home/debian/sandbox/movenet/python/movenet_multi.py", line 356, in <module>
    main()
AttributeError: '_UserObject' object has no attribute 'summary'
### movenet = loaded.signatures['serving_default'] # -->> ERROR
'serving_default'
  File "/home/debian/sandbox/movenet/python/movenet_multi.py", line 127, in main
    movenet = loaded.signatures['serving_default'] # -->> ERROR
  File "/home/debian/sandbox/movenet/python/movenet_multi.py", line 355, in <module>
    main()
KeyError: 'serving_default'

本文标签: