Open cqray1990 opened 1 year ago
for index, (pred, prob, img_name) in enumerate(zip(outputs[:, 1:], probs, file_names)): predict_text = "" # pred_list = [] pred_score_list = [] for i in range(len(pred)): # decode one sample if pred[i] == LabelTransformer.EOS: pred_score_list.append(prob[i]) break if pred[i] == LabelTransformer.UNK: continue decoded_char = LabelTransformer.decode(pred[i]) predict_text += decoded_char # pred_list.append(decoded_char) pred_score_list.append(prob[i]) pred_score = sum(pred_score_list) / len(pred_score_list) pred_item = {"filename": Path(img_name).name, "result": predict_text, "pred_score": pred_score.cpu().item()} pred_results.append(pred_item)
这段代码多行数据直接合成一条后怎么分开呢,标注的时候多行用特殊符号隔开,解码的时候怎么把两行数据分开呢,会预测出特殊符号?
这段代码多行数据直接合成一条后怎么分开呢,标注的时候多行用特殊符号隔开,解码的时候怎么把两行数据分开呢,会预测出特殊符号?