imgly / background-removal-js

Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns. Explore an interactive demo.
https://img.ly/showcases/cesdk/web/background-removal/web
GNU Affero General Public License v3.0
5.7k stars 357 forks source link

Is it possible to preload assets? #34

Open slienceisgolden opened 1 year ago

slienceisgolden commented 1 year ago

I want to preload assets before the user selects the image. How can I do that?

For my 4g connection, waiting for more than a minute is a very long time

mastrix commented 1 year ago

Hi, I'm not a maintainer but that's what I've discovered: There is a function that should take the role of warmup, but as I understand it's not public and maybe even not working, I've also tried to launch removeBackground() with a 100px image to warmup but there is no way to cancel the job, so it's taking even more time.

The only way I see is to fork the original lib or patch-package (npm lib for patching packages).

DanielHauschildt commented 1 year ago

You could also create a PR.

feedmeapples commented 6 months ago

Is https://github.com/imgly/background-removal-js/tree/main/packages/web#preloading-assets what is supposed to address this? However i don't see in code any explicit caching https://github.com/imgly/background-removal-js/blob/7dfe80f617e2d2e6d1961ec473898bed4a4ad850/packages/web/src/resource.ts#L5 , @DanielHauschildt is it meant to rely on browser caching assets implicitly? If it was meant to be explicit caching, i can send a PR if i see noticebale performance improvements