tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.35k stars 1.92k forks source link

body-pix build size is too large #7517

Open satyamgaur opened 1 year ago

satyamgaur commented 1 year ago

System information

Describe the problem We are currently using only the load function of the body-pix module, but still the file size is coming around 27mb (5.74 mb gzipped) as if tree-shaking is not at all happening. We have a very big repo, but no other package/module is leading to such a big file size, what could be the issue behind this? And how we can counter this? Also what are some recommended webpack configs for this?

gaikwadrahul8 commented 1 year ago

Hi, @satyamgaur

It seems like body-pix package is deprecated in favor of the new body-segmentation package. We have added note here. Thank you!

satyamgaur commented 1 year ago

Yeah I know it has been deprecated, but still it wasn't supposed to happen.. can you help me fixing it or what should I do to avoid this?

gaikwadrahul8 commented 1 year ago

@satyamgaur

As far I know body-pix is large model, you can check this comment and that issue conversation about body-pixmodel so May know are you facing any issue with performance ? if yes then you can refer this Tensorflow Blog which may help you to solve your issue specifically this section about model size. Thank you!

satyamgaur commented 1 year ago

I went through all the links you mentioned @gaikwadrahul8, but couldn't find anything useful for our use case. Im basically looking for some sort of aggressive tree-shaking tool/way to only load what's absolutely required for our repo - to reduce the bundle size. I've read this for example, but couldn't make how to use this for the body-pix package. Is this sort of modularisation available for body-pix? If not so, what can be done for now, and are you planning to add this in the future (in this or the replaced body-segmentation package) ?