I can't load a .dat (5MBs) file using dlib's deserialize function

18 views
Skip to first unread message

Marcos Trinca

unread,
Jun 3, 2020, 7:03:00 PM6/3/20
to emscripten-discuss
Hi there.

I succesfully compiled dlib with emscripten and I'm linking my project against the .a generated file using "target_link_libraries'. 
I've got no problems instantiating some dlib classes, I can see it's working, but as soon as I call dlib::deserialize() method I got an uncaught exception in my browser console.

The file is a .dat machine learning model.

I spent the day trying to solve this problem without success. Right now I'm guessing I'll need to use some kind of embed or preload flag. I saw fellows using it to package the entire project and preload media content but I'm not sure if my problem can be solved with this same technique.

I'll appreciate if anyone can share some tips poiting me to the right direction!
Thanks in advance.

Marcos Trinca

unread,
Jun 4, 2020, 4:36:14 PM6/4/20
to emscripten-discuss
In case someone else need this, the package tool worked for me. Reading the documentation again it seems to be the right way indeed. There's also a session about this on the "Getting Start" tutorial:

Some important steps (I'm using CMake):
1. build the project with "-s FORCE_FILESYSTEM=1"
2. after compilation run file_packager.py [data-file] --js-output=[loader-file] --preload [folder/file.dat]
My example: #python file_packager.py project.data --js-output=data_loader.js --preload models/model1.dat
3. manage your HTML file to include and start the data_loader.js before to run your module 

Notes: 
- I've ran the file_packager from inside my "js" folder (my "models" folder is inside my "js" folder).
- you can use preload or embed but the documentation strongly suggest to use preload instead of embed. 

Reply all
Reply to author
Forward
0 new messages