openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
6.81k stars 2.17k forks source link

Add signature or change default extension of weights files #26094

Open lutzroeder opened 3 weeks ago

lutzroeder commented 3 weeks ago

Issue description

OpenVINO is using the common .bin file extension to store weights. Users open such files in tools like Netron which support other formats like ncnn also defaulting to the same extension. It is not possible to reliably detect if such a file contains OpenVINO weights, and hence should be opened as OpenVINO.

Please add a unique identifier or signature to OpenVINO weights files to identify them as OpenVINO format. Also consider choosing a different file extension.

See Tencent/ncnn#5635

@yli150 @rkazants @Vladimir9812 @demid5111

Issue submission checklist

rkazants commented 3 weeks ago

Hi @lutzroeder,

In .bin file we store only weights in a raw format without any signatures and other metadata. You can differentiate OpenVINO .bin file by checking existence of .xml file of the same name along with this .bin file in the same directory. If it exists, treat it as OpenVINO, otherwise, ncnn format. You anyway parse .xml file where model topology is described.

Best regards, Roman

lutzroeder commented 3 weeks ago

@rkazants probing for other files won't work as many interactions are initialed with a URL like https://xxxxx/test.bin. It would result in triggering a series of web request to potentially slow or unreliable servers, .xml wouldn't even be first on that list. Keep in mind users might not be fully aware of these file rules, hearing the first time about OpenVINO through an existing file or exploring it in Netron. For example, the .xml file might not exist or users need to learn the pattern you describe. Instead of giving a helpful error message this becomes "this is random binary data".

The higher order issue here is that .bin is a common file extension which is often (correctly or incorrectly) used for other more popular formats with much broader adoption than OpenVINO. For example, failures to load a .bin file might be real detection issues in a more popular format which need priority but cannot be distinguished from OpenVINO users using .bin files "incorrectly".