eIQ ML: i.MX93: object detection model fails to be converted with vela

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

eIQ ML: i.MX93: object detection model fails to be converted with vela

跳至解决方案
1,393 次查看
ihermida
Contributor II

Hi guys,

This is the link to the ML guide,  https://www.nxp.com/docs/en/user-guide/IMX-MACHINE-LEARNING-UG.pdf.

Chapter "8.1.2 SSD object detection demo" uses the model ssd_mobilenet_v1_quant.tflite. The problem I found with that model is that cannot be converted with vela, thereby I cannot use the i.MX93 NPU.

Compiling manually the model "ssd_mobilenet_v1_quant.tflite", it cannot be converted, returning the next error

Error: Invalid TFLite file. Got "unpack_from requires a buffer of at least 1836597056 bytes for unpacking 4 bytes at offset 1836597052 (actual buffer size is 298)" while parsing buffers length.

 

 

 

 So, here there are two points.

  1. The script "download_models.py" should check the value when converting a model to notify about its failure, something like

 

-            os.system('vela ' + model + " --output-dir " + vela_dir)
+            ret = os.system('vela ' + model + " --output-dir " + vela_dir)
+            if ret != 0:
+                print(f"Error: Failed to convert model {name} with vela")
+                import sys
+                sys.exit(1)

 

  •  Model "ssd_mobilenet_v1_quant.tflite" is not compatible with vela/npu.
    Is it a problem of that specific model?
    What can I do to use the NPU (Ethos-U65)?

BR / Isaac

0 项奖励
回复
1 解答
1,349 次查看
pengyong_zhang
NXP Employee
NXP Employee

Hi @ihermida 

a) do you plan to fix download_models.py to report error on failure when downloading or converting the model?

>>>Actually, we have found this error before, And will fix it on the next version BSP code

b) do you know of any well known mirror where to obtain the ssd_mobilenet_v1_quant.tflite model?

>>>You can use the attachment ssd_mobilenet_v1.tflite file.

在原帖中查看解决方案

3 回复数
1,350 次查看
pengyong_zhang
NXP Employee
NXP Employee

Hi @ihermida 

a) do you plan to fix download_models.py to report error on failure when downloading or converting the model?

>>>Actually, we have found this error before, And will fix it on the next version BSP code

b) do you know of any well known mirror where to obtain the ssd_mobilenet_v1_quant.tflite model?

>>>You can use the attachment ssd_mobilenet_v1.tflite file.

1,355 次查看
ihermida
Contributor II

Hi @pengyong_zhang ,

 

The problem is that link is broken, I get an access denied from the link https://storage.googleapis.com/tfhub-lite-models/tensorflow/lite-model/ssd_mobilenet_v1/1/metadata/2...

The error is

<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist).</Details>
</Error>
 

So, as commented initially, there are two problems:

  1. The download_models.py does not report an error on failure (or well checking the downloaded file or well checking it was converted with vela)
  2. The link is broken

 

I can download that model from other locations manually, but this failure is currently broking my yocto build (as I do check if the model was correctly downloaded).

 

a) do you plan to fix download_models.py to report error on failure when downloading or converting the model?

b) do you know of any well known mirror where to obtain the ssd_mobilenet_v1_quant.tflite model?

 

BR / Isaac

0 项奖励
回复
1,365 次查看
pengyong_zhang
NXP Employee
NXP Employee

HI @ihermida 

If you can not be converted to vela model, you can delete it and re-download by yourself, then re-covert again by vela command.

I can convert it to vela model without any error on my  iMX93 EVK board.

B.R

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2015934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EeIQ%20ML%EF%BC%9Ai.MX93%EF%BC%9A%E7%89%A9%E4%BD%93%E6%A3%80%E6%B5%8B%E6%A8%A1%E5%9E%8B%E6%97%A0%E6%B3%95%E9%80%9A%E8%BF%87%20vela%20%E8%BD%AC%E6%8D%A2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2015934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%E5%A4%A7%E5%AE%B6%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%E8%BF%99%E6%98%AF%20ML%20%E6%8C%87%E5%8D%97%E7%9A%84%E9%93%BE%E6%8E%A5%EF%BC%8C%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FIMX-MACHINE-LEARNING-UG.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FIMX-MACHINE-LEARNING-UG.pdf%3C%2FA%3E%20%E3%80%82%3C%2FP%3E%3CP%3E%E7%AB%A0%E8%8A%82%E2%80%9C8.1.2%E2%80%9CSSD%20%E5%AF%B9%E8%B1%A1%E6%A3%80%E6%B5%8B%E6%BC%94%E7%A4%BA%E2%80%9D%E4%BD%BF%E7%94%A8%E6%A8%A1%E5%9E%8B%3CSPAN%3Essd_mobilenet_v1_quant.tflite%E3%80%82%E6%88%91%E5%8F%91%E7%8E%B0%E8%AF%A5%E6%A8%A1%E5%9E%8B%E7%9A%84%E9%97%AE%E9%A2%98%E6%98%AF%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%20vela%20%E8%BF%9B%E8%A1%8C%E8%BD%AC%E6%8D%A2%EF%BC%8C%E5%9B%A0%E6%AD%A4%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%20i.MX93%20NPU%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E6%89%8B%E5%8A%A8%E7%BC%96%E8%AF%91%E6%A8%A1%E5%9E%8B%E2%80%9C%20%3CSPAN%3Essd_mobilenet_v1_quant.tflite%3C%2FSPAN%3E%20%E2%80%9D%EF%BC%8C%E6%97%A0%E6%B3%95%E8%BD%AC%E6%8D%A2%EF%BC%8C%E8%BF%94%E5%9B%9E%E4%B8%8B%E4%B8%80%E4%B8%AA%E9%94%99%E8%AF%AF%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3EError%3A%20Invalid%20TFLite%20file.%20Got%20%22unpack_from%20requires%20a%20buffer%20of%20at%20least%201836597056%20bytes%20for%20unpacking%204%20bytes%20at%20offset%201836597052%20(actual%20buffer%20size%20is%20298)%22%20while%20parsing%20buffers%20length.%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%E6%89%80%E4%BB%A5%EF%BC%8C%E8%BF%99%E9%87%8C%E6%9C%89%E4%B8%A4%E7%82%B9%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%3COL%3E%3CLI%3E%3CSPAN%3E%3CSPAN%3E%E8%84%9A%E6%9C%AC%E2%80%9C%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Feiq-example%2Fblob%2Flf-6.6.52_2.2.0%2Fdownload_models.py%23L106%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Edownload_models.py%3C%2FA%3E%20%E2%80%9D%E5%BA%94%E8%AF%A5%E5%9C%A8%E8%BD%AC%E6%8D%A2%E6%A8%A1%E5%9E%8B%E6%97%B6%E6%A3%80%E6%9F%A5%E8%AF%A5%E5%80%BC%E4%BB%A5%E9%80%9A%E7%9F%A5%E5%85%B6%E5%A4%B1%E8%B4%A5%EF%BC%8C%E4%BE%8B%E5%A6%82%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FOL%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%20translate%3D%22no%22%3E-%20%20%20%20%20%20%20%20%20%20%20%20os.system('vela%20'%20%2B%20model%20%2B%20%22%20--output-dir%20%22%20%2B%20vela_dir)%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20ret%20%3D%20os.system('vela%20'%20%2B%20model%20%2B%20%22%20--output-dir%20%22%20%2B%20vela_dir)%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20if%20ret%20!%3D%200%3A%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Error%3A%20Failed%20to%20convert%20model%20%7Bname%7D%20with%20vela%22)%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20import%20sys%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sys.exit(1)%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CUL%3E%3CLI%3E%E6%A8%A1%E5%9E%8B%E2%80%9C%20%3CSPAN%3Essd_mobilenet_v1_quant.tflite%E2%80%9D%E4%B8%8Evela%2Fnpu%E4%B8%8D%E5%85%BC%E5%AE%B9%E3%80%82%3CBR%20%2F%3E%E6%98%AF%E9%82%A3%E4%B8%AA%E7%89%B9%E5%AE%9A%E5%9E%8B%E5%8F%B7%E7%9A%84%E9%97%AE%E9%A2%98%E5%90%97%EF%BC%9F%3CBR%20%2F%3E%E6%88%91%E8%AF%A5%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20NPU%EF%BC%88Ethos-U65%EF%BC%89%EF%BC%9F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%3EBR%2F%E8%89%BE%E8%90%A8%E5%85%8B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E