You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix memory leak and input sizing for SelfieSegmentation (#264)
* Dispose selfiesegmentation tensors
Adds tensor disposal code taken from the official tensorflow examples. Without it, ml5.tf.memory().numTensors shows the number of tensors in memory when running the SelfieSegmentation model kept increasing indefinitely. This wasn't an issue with the BodyPix model.
* Control selfieSegmentation input size
Added a helper function in the imageUtilities that resizes an image from an HTML img/video element to the given dimensions, and returns it as a tensor. Used it in SelfieSegmentation to make sure the input is the right size and therefore the output received by the user is not of an unexpected size.
* Return resized tensor immediately
* Adapt to suggested comment format
* Add more descriptive comment to the fix
0 commit comments