Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom dictionary visualization expects ints instead of strings #46

Open
agoryuno opened this issue Sep 15, 2023 · 0 comments
Open

Custom dictionary visualization expects ints instead of strings #46

agoryuno opened this issue Sep 15, 2023 · 0 comments

Comments

@agoryuno
Copy link

The adet/utils/visualizer.py text decoding method _ctc_decode_recognition() includes the following code:

c = int(c)
if c < self.voc_size - 1:
    if last_char != c:
        if self.voc_size == 37 or self.voc_size == 96:
            s += self.CTLABELS[c]
            last_char = c
        else:
            s += str(chr(self.CTLABELS[c]))
            last_char = c

This seems to assume that a custom character dictionary is a list containing Unicode ordinals of characters, as opposed to the characters themselves, as in the builtin dictionaries (from adet.utils.visualizer.TextVisualizer.__init__()):

if self.voc_size == 96:
    self.CTLABELS = [' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~']
elif self.voc_size == 37:
    self.CTLABELS = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9']
else:
    with open(self.use_customer_dictionary, 'rb') as fp:
        self.CTLABELS = pickle.load(fp)

Trying to use a list of characters results in:

  TypeError: 'str' object cannot be interpreted as an integer

Not sure if this was intended to be this way or was just an oversight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant