Error in instantiating pretrained ASR model
State: closed | Pull request: no
Labels: name: bug

Hi,

Getting below error while loading ASR model:-

Traceback (most recent call last):
  File "offline_asr.py", line 3, in <module>
    asr_model = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name='QuartzNet15x5Base-En', strict=False)
  File "C:\Users\e5602894\Desktop\NeMo-main\nemo\core\classes\common.py", line 407, in from_pretrained
    strict=strict,
  File "C:\Users\e5602894\Desktop\NeMo-main\nemo\core\classes\modelPT.py", line 244, in restore_from
    instance = cls.from_config_dict(config=conf)
  File "C:\Users\e5602894\Desktop\NeMo-main\nemo\core\classes\common.py", line 259, in from_config_dict
    instance = cls(cfg=config)
  File "C:\Users\e5602894\Desktop\NeMo-main\nemo\collections\asr\models\ctc_models.py", line 112, in __init__
    dist_sync_on_step=True,
TypeError: Can't instantiate abstract class WER with abstract methods forward

I was not getting this error till last week even while using 1.0.0b1 version. But after #1319 I re-downloaded source code to use CTC Beam Search Decoder with LM and getting this error.

This works to me on the latest master:
```
 model = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name='QuartzNet15x5Base-En')
```
I think we had a fix for strict=False merged recently. Could you please try again (without strict=False) and re-open the bug if the issue still persists

Just downloaded latest master again and tried to get the model still the same issue:-

Traceback (most recent call last):
  File "examples\asr\offline_asr.py", line 9, in <module>
    asr_model = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name='QuartzNet15x5Base-En')
  File ".\nemo\core\classes\common.py", line 406, in from_pretrained
    strict=strict,
  File ".\nemo\core\classes\modelPT.py", line 253, in restore_from
    instance = cls.from_config_dict(config=conf)
  File ".\nemo\core\classes\common.py", line 258, in from_config_dict
    instance = cls(cfg=config)
  File ".\nemo\collections\asr\models\ctc_models.py", line 115, in __init__
    dist_sync_on_step=True,
TypeError: Can't instantiate abstract class WER with abstract methods forward

This time I tried without 'strict'. Not sure what is going wrong here.


Could you try `asr_model = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name='QuartzNet15x5Base-En', strict=False)`

@titu1994 I have tried it with strict=False and without strict parameter. Both are giving errors as mentioned in previous comments. Please check.

@titu1994 @okuchaiev .. Tried it with both source code and pip installation, both Windows and Linux, both strict=True and False.. everywhere same error:-

    asr_model = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name='QuartzNet15x5Base-En', strict=False)
  File "C:\Users\e5602894\Desktop\NeMo-main\env_files_nemo_main\lib\site-packages\nemo_toolkit-1.0.0b2-py3.7.egg\nemo\core\classes\common.py", line 406, in from_pretrained
    strict=strict,
  File "C:\Users\e5602894\Desktop\NeMo-main\env_files_nemo_main\lib\site-packages\nemo_toolkit-1.0.0b2-py3.7.egg\nemo\core\classes\modelPT.py", line 382, in restore_from
    return cls._default_restore_from(restore_path, override_config_path, map_location, strict)
  File "C:\Users\e5602894\Desktop\NeMo-main\env_files_nemo_main\lib\site-packages\nemo_toolkit-1.0.0b2-py3.7.egg\nemo\core\classes\modelPT.py", line 303, in _default_restore_from
    instance = cls.from_config_dict(config=conf)
  File "C:\Users\e5602894\Desktop\NeMo-main\env_files_nemo_main\lib\site-packages\nemo_toolkit-1.0.0b2-py3.7.egg\nemo\core\classes\common.py", line 258, in from_config_dict
    instance = cls(cfg=config)
  File "C:\Users\e5602894\Desktop\NeMo-main\env_files_nemo_main\lib\site-packages\nemo_toolkit-1.0.0b2-py3.7.egg\nemo\collections\asr\models\ctc_models.py", line 139, in __init__
    log_prediction=self._cfg.get("log_prediction", False),
TypeError: Can't instantiate abstract class WER with abstract methods forward

Not able to reopen the issue as closed by contributor. Please reopen and help in resolving it.

The WER class does not have forward method anymore that we implement - https://github.com/NVIDIA/NeMo/blob/main/nemo/collections/asr/metrics/wer.py#L62-L181. 

Same for b2 branch. Please use reinstall.sh at the root of the Nemo directory and update pytorch lightning to 1.0.5 and try again.

@titu1994 .. upgraded to pytorch-lightning==1.0.5 and the issue is gone. Thanks a lot for your help. 👍 Closing the issue.