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

Out-of-directory calls #17

Open
AngelAquino opened this issue Jun 12, 2020 · 1 comment
Open

Out-of-directory calls #17

AngelAquino opened this issue Jun 12, 2020 · 1 comment

Comments

@AngelAquino
Copy link

Hello, and thanks for making this parser available!

I wrote a shell script which calls predict.py from an external directory, but I encounter the following error:

Traceback (most recent call last):
  File "../udify/predict.py", line 57, in <module>
    batch_size=args.batch_size)
  File "/media/sf_thesis/udify/udify/util.py", line 143, in predict_model_with_archive
    cuda_device=cuda_device)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/models/archival.py", line 230, in load_archive
    cuda_device=cuda_device)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/models/model.py", line 327, in load
    return cls.by_name(model_type)._load(config, serialization_dir, weights_file, cuda_device)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/models/model.py", line 265, in _load
    model = Model.from_params(vocab=vocab, params=model_params)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 386, in from_params
    kwargs = create_kwargs(cls, params, **extras)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 133, in create_kwargs
    kwargs[name] = construct_arg(cls, name, annotation, param.default, params, **extras)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 229, in construct_arg
    return annotation.from_params(params=subparams, **subextras)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/media/sf_thesis/udify/udify/modules/text_field_embedder.py", line 163, in from_params
    for name, subparams in token_embedder_params.items()
  File "/media/sf_thesis/udify/udify/modules/text_field_embedder.py", line 163, in <dictcomp>
    for name, subparams in token_embedder_params.items()
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/usr/local/lib/python3.6/dist-packages/allennlp/common/from_params.py", line 388, in from_params
    return cls(**kwargs)  # type: ignore
  File "/media/sf_thesis/udify/udify/modules/bert_pretrained.py", line 589, in __init__
    model = BertModel(BertConfig.from_json_file(bert_config))
  File "/usr/local/lib/python3.6/dist-packages/pytorch_pretrained_bert/modeling.py", line 206, in from_json_file
    with open(json_file, "r", encoding='utf-8') as reader:
FileNotFoundError: [Errno 2] No such file or directory: 'config/archive/bert-base-multilingual-cased/bert_config.json'

The program works fine when called from within the udify directory itself, though. Would it be possible to modify the addresses in the source code to work for external calls as well? I'd be willing to help sift through the source files for this if needed.

@Hyperparticle
Copy link
Owner

The code assumes all paths point inside the repo for simplicity. One easy workaround is to create a symlink inside the repo that points to your desired directory/file. Otherwise, it should require some code changes to the scripts to get it working, probably not too difficult. I don't have time right now to look into this myself but I welcome pull requests.

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

No branches or pull requests

2 participants