Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好我想请教下, 如何将.h5的权重换成.onnx的呢 #74

Open
tzl1 opened this issue Nov 4, 2021 · 1 comment
Open

你好我想请教下, 如何将.h5的权重换成.onnx的呢 #74

tzl1 opened this issue Nov 4, 2021 · 1 comment

Comments

@tzl1
Copy link

tzl1 commented Nov 4, 2021

以下是我做的一些尝试,但是都失败了:
import keras2onnx,keras
import onnx
from nets.yolo4 import yolo_body
from keras.models import load_model
num_anchors = 9
num_classes = 12
model_path = r'E:/python_pro/test/model_data/last1.h5'
model = yolo_body(Input(shape=(None,None,3)), num_anchors//3, num_classes)
model.load_weights(model_path)
onnx_model = keras2onnx.convert_keras(model, model.name)
temp_model_file = r'E:/python_pro/test/model_data/yolo4.onnx'
onnx.save_model(onnx_model, temp_model_file)

此段代码会报如下错误:

Using TensorFlow backend.

WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
The ONNX operator number change on the optimization: 1092 -> 474

@bubbliiiing
Copy link
Owner

sorry,这个真的难住我了,我没有弄过

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants