ViTAE-Transformer / DeepSolo

The official repo for [CVPR'23] "DeepSolo: Let Transformer Decoder with Explicit Points Solo for Text Spotting" & [ArXiv'23] "DeepSolo++: Let Transformer Decoder with Explicit Points Solo for Multilingual Text Spotting"
Other
250 stars 34 forks source link

Custom dictionary visualization expects ints instead of strings #46

Open agoryuno opened 1 year ago

agoryuno commented 1 year ago

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.