Transformer-ocr icon indicating copy to clipboard operation
Transformer-ocr copied to clipboard

AttributeError: 'numpy.ndarray' object has no attribute 'decode'

Open ritvd opened this issue 3 years ago • 1 comments

This happens here:

import torchvision.transforms as T

device = torch.device("cuda") transform = T.Compose([ T.ToTensor()]) tokenizer = Tokenizer(charset_base)

train_loader = torch.utils.data.DataLoader(DataGenerator(source_path,charset_base,max_text_length,'train',transform), batch_size=batch_size, shuffle=False, num_workers=2) val_loader = torch.utils.data.DataLoader(DataGenerator(source_path,charset_base,max_text_length,'valid',transform), batch_size=batch_size, shuffle=False, num_workers=2)

The error I get is: self.dataset[self.split]['gt'] = [x.decode() for x in self.dataset[self.split]['gt']]

AttributeError: 'numpy.ndarray' object has no attribute 'decode' #18

ritvd avatar Jun 30 '22 06:06 ritvd

Hi, Can you check your data loader, this is with it only instead of text it is getting arrays.

him4318 avatar Jul 01 '22 05:07 him4318