HELP - load model from asset failed


I tried a lot of ways to create TensorFlow lite models, and all of them end up with “Runtime Exception - TFObjectDetector loadModelFromAssetfailed”. Then I found this toolchain, and I encounter that problem again. Does this problem appear for anyone else? How I can solve it?
PS: I am using a REV Control Hub and Logitech camera.

Thanks very much!

The most important thing to understand is what an “asset” really is. An “asset” is a resource (image, sounds, videos, text, or other kind of content) that is built into a binary distribution blob. In this way, you cannot “view” the resource as a file on the file system, it’s “integrated” into the distribution. On windows, it’s common for “asset” resources to be built into “.dll” files, we similarly bundle asset resources into the app SDK - images, sounds, and even the default Tensorflow models are all bundled into the SDK and stored as assets. Since they are not located as individual files on the filesystem, but are instead integrated into a binary blob, we have to use the “LoadModelFromAsset()” function since this function knows how to index the binary blob and access the individual resources.

However, custom models aren’t built into the SDK. Instead, they’re downloaded onto the file system as an individual file. “LoadModelFromAsset()” has no idea how to find or load the file resource, since it’s not contained within the binary blob - that’s why the function call is failing (you’re effectively saying “find this resource in the asset bundle”, and it’s saying “it’s not here, dude.” Instead, we have to use the function “LoadModelFromFile()” since the custom model exists as a file, and not as a resource asset within the SDK’s binary blob.

Using the correct method for loading your model is the first step to success. Now that you understand why the two functions exist, you’re halfway there.


Detailed instructions for using a model built using the machine learning toolchain can be found in Section 6 of the user manual here.

The one caveat not covered above, and you didn’t mention which development tool you are using, but if you are using Android Studio, you can, in fact package the model as an asset for deployment to the robot controller. That’s covered in Section 6.1. If you are using OnBot Java you want to follow the instructions in Section 6.2. And Blocks is Section 6.3.

1 Like