him4318 / Transformer-ocr

Handwritten text recognition using transformers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ritvd opened this issue · comments

commented

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

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