AI4Bharat / NeMo

Apache License 2.0
3 stars 2 forks source link

Gujarati Model is not working #10

Open Kathan-Vakharia opened 2 weeks ago

Kathan-Vakharia commented 2 weeks ago

Describe the bug

Model instantiation is failing Steps/Code to reproduce bug

  1. I have only the base code given on the homepage. I tested it for the Hindi model, and it is working.

Expected behavior

A clear and concise description of what you expected to happen.

Environment overview (please complete the following information)

clone nemo

git clone https://github.com/NVIDIA/NeMo.git conda install pytorch torchvision torchaudio cpuonly -c pytorch

install NeMo

cd ../NeMo ./reinstall.sh


**Environment details**
OS: WSL
RAM:16GB

**Additional context**
Code
demo.py
```python
import torch
import IPython
import nemo.collections.asr as nemo_asr

device = torch.device("cpu")
model = nemo_asr.models.EncDecCTCModel.restore_from(restore_path='guj.nemo')
model.freeze() # inference mode
model = model.to(device)

Error:

[NeMo E 2024-10-05 17:07:17 common:529] Model instantiation failed!
    Target class:       nemo.collections.asr.models.hybrid_rnnt_ctc_bpe_models.EncDecHybridRNNTCTCBPEModel
    Error(s):   'dir'
    Traceback (most recent call last):
      File "/home/kathanv/gjstt/NeMo/nemo/core/classes/common.py", line 508, in from_config_dict
        instance = imported_cls(cfg=config, trainer=trainer)
      File "/home/kathanv/gjstt/NeMo/nemo/collections/asr/models/hybrid_rnnt_ctc_bpe_models.py", line 56, in __init__
        self._setup_tokenizer(cfg.tokenizer)
      File "/home/kathanv/gjstt/NeMo/nemo/collections/asr/parts/mixins/mixins.py", line 64, in _setup_tokenizer
        self._setup_monolingual_tokenizer(tokenizer_cfg)
      File "/home/kathanv/gjstt/NeMo/nemo/collections/asr/parts/mixins/mixins.py", line 72, in _setup_monolingual_tokenizer
        self.tokenizer_dir = self.tokenizer_cfg.pop('dir')  # Remove tokenizer directory
    KeyError: 'dir'

Traceback (most recent call last):
  File "/home/kathanv/gjstt/demo.py", line 6, in <module>
    model = nemo_asr.models.EncDecCTCModel.restore_from(restore_path='guj.nemo')
  File "/home/kathanv/gjstt/NeMo/nemo/core/classes/modelPT.py", line 468, in restore_from
    instance = cls._save_restore_connector.restore_from(
  File "/home/kathanv/gjstt/NeMo/nemo/core/connectors/save_restore_connector.py", line 260, in restore_from
    loaded_params = self.load_config_and_state_dict(
  File "/home/kathanv/gjstt/NeMo/nemo/core/connectors/save_restore_connector.py", line 182, in load_config_and_state_dict
    instance = calling_cls.from_config_dict(config=conf, trainer=trainer)
  File "/home/kathanv/gjstt/NeMo/nemo/core/classes/common.py", line 530, in from_config_dict
    raise e
  File "/home/kathanv/gjstt/NeMo/nemo/core/classes/common.py", line 522, in from_config_dict
    instance = cls(cfg=config, trainer=trainer)
  File "/home/kathanv/gjstt/NeMo/nemo/collections/asr/models/ctc_models.py", line 72, in __init__
    if self.cfg.decoder.num_classes < 1 and self.cfg.decoder.vocabulary is not None:
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/dictconfig.py", line 355, in __getattr__
    self._format_and_raise(
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/base.py", line 231, in _format_and_raise
    format_and_raise(
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/_utils.py", line 899, in format_and_raise
    _raise(ex, cause)
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/_utils.py", line 797, in _raise
    raise ex.with_traceback(sys.exc_info()[2])  # set env var OC_CAUSE=1 for full trace
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/dictconfig.py", line 351, in __getattr__
    return self._get_impl(
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/dictconfig.py", line 442, in _get_impl
    node = self._get_child(
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/basecontainer.py", line 73, in _get_child
    child = self._get_node(
  File "/home/kathanv/miniconda3/envs/temo/lib/python3.10/site-packages/omegaconf/dictconfig.py", line 480, in _get_node
    raise ConfigKeyError(f"Missing key {key!s}")
omegaconf.errors.ConfigAttributeError: Missing key num_classes
    full_key: decoder.num_classes
    object_type=dict