(label)
| 67 | return length, text_input, text_all, None, None, None, string_label, loc_gt |
| 68 | |
| 69 | def converter_ocr(label): |
| 70 | string_label = label |
| 71 | label = [i for i in label] |
| 72 | alp2num = alp2num_character |
| 73 | |
| 74 | batch = len(label) |
| 75 | length = torch.Tensor([len(i) for i in label]).long().cuda() |
| 76 | max_length = max(length) |
| 77 | |
| 78 | text_input = torch.zeros(batch, max_length).long().cuda() |
| 79 | for i in range(batch): |
| 80 | for j in range(len(label[i]) - 1): |
| 81 | text_input[i][j + 1] = alp2num[label[i][j]] |
| 82 | |
| 83 | sum_length = sum(length) |
| 84 | text_all = torch.zeros(sum_length).long().cuda() |
| 85 | start = 0 |
| 86 | for i in range(batch): |
| 87 | for j in range(len(label[i])): |
| 88 | if j == (len(label[i])-1): |
| 89 | text_all[start + j] = alp2num['END'] |
| 90 | else: |
| 91 | text_all[start + j] = alp2num[label[i][j]] |
| 92 | start += len(label[i]) |
| 93 | |
| 94 | return length, text_input, text_all, None, None, None, string_label |
| 95 | |
| 96 | |
| 97 | def get_alphabet(alpha_path): |
nothing calls this directly
no outgoing calls
no test coverage detected