intel / webml-polyfill

Deprecated, the Web Neural Network Polyfill project has been moved to https://github.com/webmachinelearning/webnn-polyfill
Apache License 2.0
161 stars 42 forks source link

Reduce file size of OpenCV.js for OpenCV.js Threshold workload #1364

Closed ibelem closed 4 years ago

ibelem commented 4 years ago

The file size of OpenCV.js is 8.1MB (Wasm) and 9.0MB (Threads+SIMD) which is too huge, there should be some parameters to use to reduce the file size, we only need a deep learning module.

We could try to change

white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, photo, aruco, calib3d])

to

white_list = makeWhiteList([core, imgproc, dnn])

in

https://github.com/opencv/opencv/blob/master/platforms/js/opencv_js.config.py

then follow https://docs.opencv.org/4.3.0/d4/da1/tutorial_js_setup.html to build OpenCV.js.

Based on https://github.com/intel/webml-polyfill/pull/1326, @akineeic built the files with emscripten 1.39.15 and opencv 4.3.0.

@BruceDai please try it when you have time and compare the file sizes.

BruceDai commented 2 years ago

We verified with Emsdk 2.0.32 + opencv 4.5.2.