test_torchscripts.py 477 B

1234567891011121314151617
  1. import torch
  2. import numpy as np
  3. if __name__ == '__main__':
  4. onnx_path = "/nfs/zhifu.gzf/export/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/model.torchscripts"
  5. loaded = torch.jit.load(onnx_path)
  6. x = torch.rand([2, 21, 560])
  7. x_len = torch.IntTensor([6, 21])
  8. res = loaded(x, x_len)
  9. print(res[0].size(), res[1])
  10. x = torch.rand([5, 50, 560])
  11. x_len = torch.IntTensor([6, 21, 10, 30, 50])
  12. res = loaded(x, x_len)
  13. print(res[0].size(), res[1])