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

Load back translation models from local path #149

Closed
Samarthagarwal23 opened this issue Sep 18, 2020 · 5 comments
Closed

Load back translation models from local path #149

Samarthagarwal23 opened this issue Sep 18, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@Samarthagarwal23
Copy link

By default, it tries to download from torch hub.
Can you enable functionality to load model from local path?

@makcedward
Copy link
Owner

Enhanced in version 1.0.0. Will be released by end of this month. Before that you can try to pull from github for earlier access.

You need to set new parameter (i.e. is_load_from_github) to False. The following is a sample code or you can go to this notebook for reference.

# Load models from local path
import nlpaug.augmenter.word as naw

from_model_dir = os.path.join(os.environ["MODEL_DIR"], 'word', 'fairseq', 'wmt19.en-de')
to_model_dir = os.path.join(os.environ["MODEL_DIR"], 'word', 'fairseq', 'wmt19.de-en')

text = 'The quick brown fox jumped over the lazy dog'
back_translation_aug = naw.BackTranslationAug(
    from_model_name=from_model_dir, from_model_checkpt='model1.pt',
    to_model_name=to_model_dir, to_model_checkpt='model1.pt', 
    is_load_from_github=False)
back_translation_aug.augment(text)

makcedward added a commit that referenced this issue Sep 19, 2020
BackTranslation supports loading model from local directory #149
@makcedward
Copy link
Owner

Fixed in 1.0.0 version

@Enriquesec
Copy link

Hi, I'm trying to load a model from a local path (using version 1.1.10), but I'm getting an error.

image

Does the example above (or in the example notebook) only work for version 1.0.0? Or How can I reload translation models from a local path?

Thanks

@Meywether
Copy link

Meywether commented Mar 28, 2022

'+' 1
Same error, on Windows.

@makcedward
Copy link
Owner

You may access this notebook for examples or you can try the following code.

import nlpaug.augmenter.word as naw

text = 'The quick brown fox jumped over the lazy dog'
back_translation_aug = naw.BackTranslationAug(
    from_model_name='facebook/wmt19-en-de', 
    to_model_name='facebook/wmt19-de-en'
)
back_translation_aug.augment(text)

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

4 participants