Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

python - How do I properly convert a h5 file to pb

So I trained a model using https://teachablemachine.withgoogle.com/ and it gave me a keras_model.h5 file and a labels.txt and I want to use it with OpenCV for some object detection but I've only used OpenCV with .pb files. So I'm thinking that I would have to convert it somehow. So I started looking around and I found this. https://github.com/amir-abdi/keras_to_tensorflow and when I try to run the script in my conda environment it throws this exception.

WARNING:tensorflow:From keras_to_tensorflow.py:23: set_learning_phase (from tensorflow.python.keras.backend) is deprecated and will be removed after 2020-10-11.
Instructions for updating:
Simply pass a True/False value to the `training` argument of the `__call__` method of your layer or model.
2021-01-23 05:58:15.012748: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
I0123 05:58:16.157379  5660 keras_to_tensorflow.py:145] Converted output node names are: ['sequential_3/dense_Dense2/Softmax']
Traceback (most recent call last):
  File "keras_to_tensorflow.py", line 182, in <module>
    app.run(main)
  File "C:Usersdeveloperminiconda3envsf1libsite-packagesabslapp.py", line 303, in run
    _run_main(main, args)
  File "C:Usersdeveloperminiconda3envsf1libsite-packagesabslapp.py", line 251, in _run_main
    sys.exit(main(argv))
  File "keras_to_tensorflow.py", line 148, in main
    sess = K.get_session()
AttributeError: module 'keras.backend' has no attribute 'get_session'

Why is that and how do I properly convert it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...