Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Size discrepancy in conversion #138

Open
jcsm89 opened this issue Apr 13, 2023 · 1 comment
Open

Size discrepancy in conversion #138

jcsm89 opened this issue Apr 13, 2023 · 1 comment

Comments

@jcsm89
Copy link

jcsm89 commented Apr 13, 2023

Issue Type

Performance

OS

Windows

OS architecture

x86_64

Programming Language

Python

Framework

TensorFlow

Download URL for ONNX / OpenVINO IR

https://drive.google.com/drive/folders/1Di7vhQfd-5DLGDUSII1_NxLvEvs2fXpI?usp=sharing

Convert Script

Conversion was performed on the model.xml OpenVino model (included in the Drive directory above) with the unchanged openvino2tensorflow.py script (commit hash 63fff40). I tested both on the Docker and on a local clone of the repository and the same issue was observed.

python openvino2tensorflow.py --model_path C:\dev\openvino_model\model.xml --output_weight_and_json --model_output_path C:\dev\converted_model

Description

While converting an OpenVino model to Tensorflow (in json architecture + h5 weights format) it was observed that the size of the resulting files (namely the json file) was much larger than the original model in OpenVino format. More precisely, the original OpenVino bin file was 254MB in size, while the resulting json was 1394MB and the resulting h5 weights file was 205MB in size.

All models are included in the Google Drive folder shared above, including the original ONNX model (can also be downloaded in its original form from https://drive.google.com/file/d/1Gh8C-bwl2B90RDrvKJkXafvZC3q4_H_z/view?usp=sharing). The conversion to OpenVino was performed using OpenVino 2021.4.1, with all the details consultable in the metadata section of the xml file.

We noticed that the resulting architecture file has a lot of numeric values in it, whereas a normal json architecture file only has info about the tensors and how they are connected to form the full model scheme. Not sure if this helps in any way to pinpoint the issue.

Also of note that the number of parameters in the model is consistent when loading the converted model in Python using load_model, which seems to indicate that the architecture and the weights are consistent but, for some reason, occupy a lot more space in disk. Also, the models take a long time to load in Python and timeout Netron visualization.

If you need any more details just let me know and thanks in advance!

conversion_logs.txt

Relevant Log Output

The logs were too large to include, just attached them in the description.

Source code for simple inference testing code

Just run the conversion script pointing to model.xml and it should output the large json + similar sized h5 weights file.

@PINTO0309
Copy link
Owner

PINTO0309 commented Apr 13, 2023

The specifications have remained that way since the beginning. It is a TensorFlow specification rather than a tool issue. Therefore, I am deprecating output by h5.

The situation may not change much, but if you own an onnx, I recommend the following tool, which I have been actively maintaining recently. The conversion efficiency is much higher than openvino2tensorflow.

https://github.com/PINTO0309/onnx2tf

I checked only the structure of the model with Netron, and it looks like a simple model with fairly low conversion difficulty, so it will probably succeed.

I will be out of town for three days starting today and will not be able to operate a PC, so I can only read the text of the issue on my tablet.

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

No branches or pull requests

2 participants