mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-13 13:47:36 +02:00
Catch invalid character index in lpr CTC decoder (#18825)
This commit is contained in:
parent
52e5429b33
commit
b17f0c4a30
@ -1610,9 +1610,9 @@ class CTCDecoder:
|
|||||||
self.characters = []
|
self.characters = []
|
||||||
if character_dict_path and os.path.exists(character_dict_path):
|
if character_dict_path and os.path.exists(character_dict_path):
|
||||||
with open(character_dict_path, "r", encoding="utf-8") as f:
|
with open(character_dict_path, "r", encoding="utf-8") as f:
|
||||||
self.characters = ["blank"] + [
|
self.characters = (
|
||||||
line.strip() for line in f if line.strip()
|
["blank"] + [line.strip() for line in f if line.strip()] + [" "]
|
||||||
]
|
)
|
||||||
else:
|
else:
|
||||||
self.characters = [
|
self.characters = [
|
||||||
"blank",
|
"blank",
|
||||||
@ -1747,7 +1747,7 @@ class CTCDecoder:
|
|||||||
merged_path.append(char_index)
|
merged_path.append(char_index)
|
||||||
merged_probs.append(seq_log_probs[t, char_index])
|
merged_probs.append(seq_log_probs[t, char_index])
|
||||||
|
|
||||||
result = "".join(self.char_map[idx] for idx in merged_path)
|
result = "".join(self.char_map.get(idx, "") for idx in merged_path)
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
|
||||||
confidence = np.exp(merged_probs).tolist()
|
confidence = np.exp(merged_probs).tolist()
|
||||||
|
Loading…
Reference in New Issue
Block a user