Open semihcanturk opened 4 years ago
I use an automated translation site, so please forgive us if it is difficult to read.
"keras2onnx", "onnx", "onnxconverter-common" versions, etc. could be the problem.
I'm using a different repository, with a different version of "keras2onnx", but I hope this will be of some help.
Repositories used
https://github.com/axinc-ai/yolov3-face https://github.com/qqwweee/keras-yolo3
Clone the source
Clone from axinc-ai/yolov3-face with git
git clone https://github.com/axinc-ai/yolov3-face.git
Clone keras-yolo3 linked in yolov3-face
cd .\yolov3-face
git clone https://github.com/qqwweee/keras-yolo3.git
Conversion
Creating the conversion environment
Create the virtual environment "yolov3-face" with conda
conda create -n yolov3-face python=3.6 -y
Install the necessary modules. As the version is specified in "axinc-ai/yolov3-face" and is not available in the conda repository, install it by pip.
conda activate yolov3-face
pip install tensorflow==1.13.2
pip install keras==2.2.4
pip install keras2onnx==1.5.1
pip install opencv-python
pip install pillow
pip install matplotlib
Perform version down of "onnxconverter-common" and "onnx".
"axinc-ai/yolov3-face" does not work with ONNX 1.7.0 (ONNX v7), so I had to use ONNX v6.
Reduce to onnx==1.6.0 and onnxconverter-common==1.6.0.
pip install onnxconverter-common==1.6.0
pip install onnx==1.6.0
To support TensorRT 5.x, do the following
pip install onnxconverter-common==1.6.0
pip install onnx==1.4.1
Perform the conversion
cd .\keras-onnx
conda activate yolov3-face
python keras-yolo3-to-onnx.py ../model_data/logs/trained_weights_final.h5 ../model_data/face_classes.txt ../model_data/tiny_yolo_anchors.txt ../model_data/ax_face.onnx
Inference
Create an environment for inference
Create the virtual environment "yolov3-face-inference" with conda
conda create -n yolov3-face-inference python=3.6 -y
Install the necessary modules. As the version is specified in "axinc-ai/yolov3-face" and is not available in the conda repository, install it by pip.
conda activate yolov3-face-inference
pip install tensorflow==1.13.2
pip install onnxruntime
pip install keras==2.2.4
pip install pillow
Perform the inference
cd .\keras-onnx
conda activate yolov3-face-inference
python inference.py ../model_data/ax_face.onnx ../model_data/face_classes.txt ../images/couple.jpg output.jpg
reference
https://qiita.com/tfukumori/items/66966074b746bc815f18 The results of "conda list" are described. This is a web page in Japanese.
I am trying to convert the YOLOv3 model here to ONNX. This is also crossposted to the keras-onnx repository (https://github.com/onnx/keras-onnx/issues/606), but I wanted to post it here for outreach as well given that it may be of interest to others.
The README on https://github.com/onnx/keras-onnx/tree/master/applications/yolov3 states the following:
When I try to run https://github.com/onnx/keras-onnx/blob/master/applications/yolov3/yolov3.py after following the Quick Start section, I get the following error:
I'm using the following relevant package versions: keras2onnx 1.7.1 (latest master) onnx 1.7.0 onnxconverter-common 1.7.0 (latest master) onnxruntime 1.4.0 tensorflow 2.2.0 (I've also tried with 2.0.2, and am using tensorflow.keras with TF_KERAS=1)
I've tried with opsets 10 to 12 along with the respective ONNX versions, but haven't been able to resolve the issue. Any help is much appreciated