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

What's the right way of using the decode_word in other modules #148

Open
bobzsj87 opened this issue Aug 14, 2018 · 1 comment
Open

What's the right way of using the decode_word in other modules #148

bobzsj87 opened this issue Aug 14, 2018 · 1 comment

Comments

@bobzsj87
Copy link

Hi,

I am trying to load G2PModel instance which is to be shared by other applications (e.g. an HTTP server). When I tried to use the model.decode_word, it says res_iter is not in the model. Until I manually run interactive() or run the private method._G2PModel__prepare_interactive_model() could everything be initialized. Then run the decode_word for the first time. After that, each word decode is lightning fast.

What's the clean way of getting everything initialized and use the model to decode_word from the application?

@bobzsj87
Copy link
Author

bobzsj87 commented May 21, 2019

I added the following method in the app.py, so it will return an initialized model, which can be cached and reused in decode_word

`
def standalone_model(model_dir):
if not model_dir:
raise RuntimeError("Model directory not specified.")

params = Params(model_dir, '')
params.hparams = g2p_trainer_utils.load_params(model_dir)
model = G2PModel(params)

model.inputs = [] # initialization
model._G2PModel__prepare_interactive_model()
model.decode_word('apple') # run for the first time
return model
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant