module 'torch' has no attribute 'inference_mode'

#1
by MonsterMMORPG - opened

Hello. I am trying to make it run and compare with felflare-bert-restore-punctuation but getting this error

image.png

from typing import List

from punctuators.models import PunctCapSegModelONNX
m = PunctCapSegModelONNX.from_pretrained("pcs_en")
input_texts = example
results = m.infer(input_texts)

Hi,

You may need to update PyTorch; I did not pin a minimum version in the requirements..

torch.inference_mode was introduced in PyTorch 1.9.

Hi,

You may need to update PyTorch; I did not pin a minimum version in the requirements..

torch.inference_mode was introduced in PyTorch 1.9.

hi it worked but looks like i am not using the correct strategy

I gave input like this

image.png

the output is not correct

image.png

this is the code

from punctuators.models import PunctCapSegModelONNX
m = PunctCapSegModelONNX.from_pretrained("pcs_en")
input_texts = example
results = m.infer(input_texts)
with open('punctuation_fullstop_truecase_english.txt', 'w') as f:
    f.writelines(result)

by the way it doesn't work with torch 2. works with torch 1.13

Sign up or log in to comment