最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

tensorflow - How can I save a model with input shape (1, None, None, 3) with None fixed to 256? - Stack Overflow

programmeradmin5浏览0评论

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'

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论