Volcomix / virtual-background

Demo on adding virtual background to a live video stream in the browser
https://volcomix.github.io/virtual-background
Apache License 2.0
487 stars 124 forks source link

tflite.js and tflite-simd.js size increased #40

Closed benbro closed 2 years ago

benbro commented 2 years ago

I've noticed that the size of the tflite files increased significantly after https://github.com/Volcomix/virtual-background/commit/ae6db18c27e50351f717531dacc5c7a7bc9bd8b0 Is there a reason for such increase for the same functionality?

public/tflite/tflite.js Before = 16.4 KB After = 72 KB

public/tflite/tflite-simd.wasm Before = 2.51 MB After = 2.81 MB

Mabe because --features=wasm_simd was added but -c opt --copt='-msimd128' wasn't removed. https://github.com/Volcomix/virtual-background/commit/fae12a227572b373730a82a08ee2e6ad856d83f7 https://github.com/google/XNNPACK/commit/322055148b47dccb76bc03ad010f16c1e3a94817

Volcomix commented 2 years ago

Looks like filesystem API was embedded into the tflite builds (https://emscripten.org/docs/api_reference/Filesystem-API.html). Maybe some changes in TensorFlow added some dependencies with those functions but after testing without them, this demo is still working fine. So I removed those API in https://github.com/Volcomix/virtual-background/pull/42. tflite.js is now around 24 KB.

benbro commented 2 years ago

Thanks. -c opt --copt='-msimd128' is still needed?

Volcomix commented 2 years ago

Good point, I tested a build without and indeed the result is the same for the SIMD build. Removed in https://github.com/Volcomix/virtual-background/pull/43. Thanks!

benbro commented 2 years ago

Thanks