NeMo
NeMo copied to clipboard
Can't redefine method: __filter_banks_getter on class: __torch__.nemo.collections.asr.parts.preprocessing.features.FilterbankFeatures
Steps/Code to reproduce bug
I'm trying to repeat the model deployment instruction on Android.
from torch.utils.mobile_optimizer import optimize_for_mobile
pretrained_model = nemo_asr.models.EncDecCTCModel.load_from_checkpoint(
"my_model.ckpt",
map_location="cpu"
)
pretrained_model.eval()
pretrained_model.encoder.freeze()
pretrained_model.decoder.freeze()
quantized_model = torch.quantization.quantize_dynamic(
pretrained_model, qconfig_spec={torch.nn.Linear}, dtype=torch.qint8, inplace=True
)
scripted_model = torch.jit.script(quantized_model)
# optimized_model = optimize_for_mobile(scripted_model)
But torch.jit.script returns an error:
RuntimeError: Can't redefine method: __filter_banks_getter on class: torch.nemo.collections.asr.parts.preprocessing.features.FilterbankFeatures (of Python compilation unit at: ...)
Can you advise how to fix this?
Nemo models are not pickleable so that will not work. If all you need to do is export, then we have model.export(), you can try that. If exports to onnx and somethings can be exported to torchscript too.
Am I right, are you suggesting to convert the model to onnx using the built in model.export("model.onnx") method and then call torch.jit.script on the onnx?
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.