microsoft / unilm

Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
https://aka.ms/GeneralAI
MIT License
19.11k stars 2.44k forks source link

ModuleNotFoundError: No module named 'unilm_models' #589

Open shuuchen opened 2 years ago

shuuchen commented 2 years ago

Hi,

I am following this command for fine-tuning on IAM but got the error:

Traceback (most recent call last):
  File "/home/shuchen/miniconda3/envs/trocr/bin/fairseq-train", line 8, in <module>
    sys.exit(cli_main())
  File "/home/shuchen/miniconda3/envs/trocr/lib/python3.7/site-packages/fairseq_cli/train.py", line 494, in cli_main
    parser = options.get_training_parser()
  File "/home/shuchen/miniconda3/envs/trocr/lib/python3.7/site-packages/fairseq/options.py", line 37, in get_training_parser
    parser = get_parser("Trainer", default_task)
  File "/home/shuchen/miniconda3/envs/trocr/lib/python3.7/site-packages/fairseq/options.py", line 217, in get_parser
    utils.import_user_module(usr_args)
  File "/home/shuchen/miniconda3/envs/trocr/lib/python3.7/site-packages/fairseq/utils.py", line 478, in import_user_module
    importlib.import_module(module_name)
  File "/home/shuchen/miniconda3/envs/trocr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/shuchen/data/github/unilm/trocr/__init__.py", line 5, in <module>
    from .deit_models import TrOCRModel
  File "/home/shuchen/data/github/unilm/trocr/deit_models.py", line 32, in <module>
    from unilm_models import UniLMDecoder
ModuleNotFoundError: No module named 'unilm_models'

--finetune-from-model: command not found

I did that in the unlim/trocr directory. Hope to help me out. Thank you.

vittoriopippi commented 2 years ago

The reason why you got that error is that they placed a bare except during the module import here.

First of all, I suggest adding ModuleNotFoundError to the exception clause, then if you run the script again, probably you will get another error.

I don't know which error caused your exception, but if it is my same error you will probably need to watch this other issue: #597

RishabhMaheshwary commented 2 years ago

I am also getting the same error message.