rembg
rembg copied to clipboard
[FEATURE] Use downloaded model on Cloud Function
First, thanks a lot for this amazing tool!
Use case
Following the issue @maumarteau raised, I would like to know if it is planned (or not) to be able to use a given model locally.
In my use case, I use a Google Cloud Function which is hosting a Python script to use this background removal feature. However, when there is no Cloud Function available, it has to start and when it is run, it downloads the model:
Downloading data from 'https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx' to file '/tmp/.u2net/u2net.onnx'.
With a progress bar to let us know when it is ready to be used (related sourcecode: sam.py:275). Once the model is downloaded, the background removal is done and I am able to retrieve a processed image (yay!).
Problem
Because of this Cloud Function cold start, it requires to wait the model to be download, which is quite long in some use case. If the Cloud Function is already available, it is quite fast, but the policy to keep awake the Cloud Function does not allow me to keep this Cloud Function for ever.
Solution
Suggested solution:
- Is it planned to be able to use a local model or not?
- Is it planned to have the ability to specify a path to load the model (for instance in a Google Cloud Storage / Bucket)?
Thanks a lot!