Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Offline use of model #108

Closed
Phil1108 opened this issue Nov 17, 2021 · 7 comments
Closed

Feature request - Offline use of model #108

Phil1108 opened this issue Nov 17, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Phil1108
Copy link

At the moment it is nearly impossible to create a docker container that works offline (without internet access).
Even if you include this line during docker build:

RUN python -c "import torch; torch.backends.quantized.engine='qnnpack'; torch.hub.load(repo_or_dir='snakers4/silero-models', model='silero_te', force_reload=True)"

During execution of the docker container (without internet) you load it locally:

torch.hub.load(repo_or_dir='/root/.cache/torch/hub/snakers4_silero-models_master', model='silero_te', source='local', force_reload=False)

Then you have the problem that the hubconf.py is called again (and fails due to no internet access) and it tries to download the files in hubconf.py Lines 21, 49, 101, even though they already exist.

So my suggestion would be to also includes checks in the Lines 21,49,101 to check if the file already exists locally and if yes then skip it (like done in Line 114)

Any reasons against that?

@Phil1108 Phil1108 added the enhancement New feature or request label Nov 17, 2021
@snakers4
Copy link
Owner

Hi,

Then you have the problem that the hubconf.py is called again (and fails due to no internet access) and it tries to download the files in hubconf.py Lines 21, 49, 101, even though they already exist.

Many thanks for catching this, this is a valid edge case. This is not intentional.

Originally I believed that people using these models locally would just override the hubconf.py with their own init functions. At that moment I needed a list of models to be loaded before doing the rest, so I just used the simplest dumbest solution and never gave it a second thought.

So my suggestion would be to also includes checks in the Lines 21,49,101 to check if the file already exists locally and if yes then skip it (like done in Line 114)
Any reasons against that?

I do not know why I overlooked this method hub_dir = torch.hub.get_dir().
Since you are already using pytorch.hub cache, maybe just load the .yml file from hub_dir, if it exists?

A small PR would be greatly appreciated.

axenov added a commit to axenov/silero-models that referenced this issue Nov 19, 2021
@axenov
Copy link
Contributor

axenov commented Nov 19, 2021

@snakers4 I have added a small fix to the issue.

@snakers4
Copy link
Owner

Just a small question, why use __file__ instead of hub_dir = torch.hub.get_dir()?

@axenov
Copy link
Contributor

axenov commented Nov 19, 2021

torch.hub.get_dir() returns path to the whole torch.hub cache and not only cache of silero-models. You used __file__ to get the right directory bellow: https://github.com/snakers4/silero-models/blob/master/hubconf.py#L69

snakers4 added a commit that referenced this issue Nov 19, 2021
fix local load snakers4/silero-models/#108
@snakers4
Copy link
Owner

Merged #111
Checked that all of the main examples work (STT, TTS, TE)

@snakers4
Copy link
Owner

Please verify, that it runs locally with your build now and close

@Phil1108
Copy link
Author

Yeah works like a charm. Thanks @snakers4 and @axenov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants