Holmeyoung / crnn-pytorch

Pytorch implementation of CRNN (CNN + RNN + CTCLoss) for all language OCR.
MIT License
378 stars 105 forks source link

[Friendly reminder] About the accuracy of demo.py #73

Closed HaliComing closed 2 years ago

HaliComing commented 2 years ago

If you are training, the loss is low and the validation dataset accuracy is high, but when executing demo.py, the accuracy is very low. You can refer to the following code to modify (demo.py):

converter = utils.strLabelConverter(params.alphabet)

transformer = dataset.resizeNormalize((100, 32))
image = Image.open(image_path).convert('L')
image = transformer(image)
if torch.cuda.is_available():

to

converter = utils.strLabelConverter(params.alphabet)

image = Image.open(image_path).convert('L')
image = transforms.ToTensor()(image)
image.sub_(0.5).div_(0.5)
if torch.cuda.is_available():

enjoy !!!