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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
1,487 Views
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 Kudos
Reply
1 Solution
1,443 Views
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.

View solution in original post

3 Replies
1,444 Views
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,449 Views
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 Kudos
Reply
1,459 Views
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 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2015934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EeIQ%20ML%3A%20i.MX93%3A%20object%20detection%20model%20fails%20to%20be%20converted%20with%20vela%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2015934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3EThis%20is%20the%20link%20to%20the%20ML%20guide%2C%26nbsp%3B%26nbsp%3B%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.%3C%2FP%3E%3CP%3EChapter%20%228.1.2%20SSD%20object%20detection%20demo%22%20uses%20the%20model%26nbsp%3B%3CSPAN%3Essd_mobilenet_v1_quant.tflite.%20The%20problem%20I%20found%20with%20that%20model%20is%20that%20cannot%20be%20converted%20with%20vela%2C%20thereby%20I%20cannot%20use%20the%20i.MX93%20NPU.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ECompiling%20manually%20the%20model%20%22%3CSPAN%3Essd_mobilenet_v1_quant.tflite%3C%2FSPAN%3E%22%2C%20it%20cannot%20be%20converted%2C%20returning%20the%20next%20error%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%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%3ESo%2C%20here%20there%20are%20two%20points.%3C%2FSPAN%3E%3C%2FP%3E%3COL%3E%3CLI%3E%3CSPAN%3E%3CSPAN%3EThe%20script%20%22%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%22%20should%20check%20the%20value%20when%20converting%20a%20model%20to%20notify%20about%20its%20failure%2C%20something%20like%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%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%26nbsp%3BModel%20%22%3CSPAN%3Essd_mobilenet_v1_quant.tflite%22%20is%20not%20compatible%20with%20vela%2Fnpu.%3CBR%20%2F%3EIs%20it%20a%20problem%20of%20that%20specific%20model%3F%3CBR%20%2F%3EWhat%20can%20I%20do%20to%20use%20the%20NPU%20(Ethos-U65)%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%3EBR%20%2F%20Isaac%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2017029%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20eIQ%20ML%3A%20i.MX93%3A%20object%20detection%20model%20fails%20to%20be%20converted%20with%20vela%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2017029%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F161288%22%20target%3D%22_blank%22%3E%40ihermida%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ea)%20do%20you%20plan%20to%20fix%20download_models.py%20to%20report%20error%20on%20failure%20when%20downloading%20or%20converting%20the%20model%3F%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26gt%3B%26gt%3B%26gt%3BActually%2C%20we%20have%20found%20this%20error%20before%2C%20And%20will%20fix%20it%20on%20the%20next%20version%20BSP%20code%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3Eb)%20do%20you%20know%20of%20any%20well%20known%20mirror%20where%20to%20obtain%20the%26nbsp%3Bssd_mobilenet_v1_quant.tflite%20model%3F%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26gt%3B%26gt%3B%26gt%3BYou%20can%20use%20the%20attachment%26nbsp%3Bssd_mobilenet_v1.tflite%20file.%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2017019%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20eIQ%20ML%3A%20i.MX93%3A%20object%20detection%20model%20fails%20to%20be%20converted%20with%20vela%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2017019%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F202673%22%20target%3D%22_blank%22%3E%40pengyong_zhang%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20problem%20is%20that%20link%20is%20broken%2C%20I%20get%20an%20access%20denied%20from%20the%20link%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstorage.googleapis.com%2Ftfhub-lite-models%2Ftensorflow%2Flite-model%2Fssd_mobilenet_v1%2F1%2Fmetadata%2F2.tflite%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstorage.googleapis.com%2Ftfhub-lite-models%2Ftensorflow%2Flite-model%2Fssd_mobilenet_v1%2F1%2Fmetadata%2F2.tflite%2C%3C%2FA%3E%3C%2FP%3E%3CP%3EThe%20error%20is%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CERROR%3E%0A%3CCODE%3EAccessDenied%3C%2FCODE%3E%0A%3CMESSAGE%3EAccess%20denied.%3C%2FMESSAGE%3E%0A%3CDETAILS%3EAnonymous%20caller%20does%20not%20have%20storage.objects.get%20access%20to%20the%20Google%20Cloud%20Storage%20object.%20Permission%20'storage.objects.get'%20denied%20on%20resource%20(or%20it%20may%20not%20exist).%3C%2FDETAILS%3E%0A%3C%2FERROR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3ESo%2C%20as%20commented%20initially%2C%20there%20are%20two%20problems%3A%3C%2FP%3E%3COL%3E%3CLI%3EThe%20download_models.py%20does%20not%20report%20an%20error%20on%20failure%20(or%20well%20checking%20the%20downloaded%20file%20or%20well%20checking%20it%20was%20converted%20with%20vela)%3C%2FLI%3E%3CLI%3EThe%20link%20is%20broken%3C%2FLI%3E%3C%2FOL%3E%3CBR%20%2F%3E%3CP%3EI%20can%20download%20that%20model%20from%20other%20locations%20manually%2C%20but%20this%20failure%20is%20currently%20broking%20my%20yocto%20build%20(as%20I%20do%20check%20if%20the%20model%20was%20correctly%20downloaded).%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ea)%20do%20you%20plan%20to%20fix%20download_models.py%20to%20report%20error%20on%20failure%20when%20downloading%20or%20converting%20the%20model%3F%3C%2FP%3E%3CP%3Eb)%20do%20you%20know%20of%20any%20well%20known%20mirror%20where%20to%20obtain%20the%26nbsp%3Bssd_mobilenet_v1_quant.tflite%20model%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBR%20%2F%20Isaac%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2016911%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20eIQ%20ML%3A%20i.MX93%3A%20object%20detection%20model%20fails%20to%20be%20converted%20with%20vela%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2016911%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHI%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F161288%22%20target%3D%22_blank%22%3E%40ihermida%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20can%20not%26nbsp%3Bbe%20converted%20to%20vela%20model%2C%20you%20can%20delete%20it%20and%20re-download%20by%20yourself%2C%20then%20re-covert%20again%20by%20vela%20command.%3C%2FP%3E%0A%3CP%3EI%20can%20convert%20it%20to%20vela%20model%20without%20any%20error%20on%20my%26nbsp%3B%20iMX93%20EVK%20board.%3C%2FP%3E%0A%3CP%3EB.R%3C%2FP%3E%3C%2FLINGO-BODY%3E