From 2734733630c37abd1b63296e96536eca1ccb4620 Mon Sep 17 00:00:00 2001 From: FLming Date: Wed, 21 Oct 2020 09:12:02 +0000 Subject: [PATCH] Fix bug: Errors caused by disordered dictionary --- ppocr/modeling/architectures/rec_model.py | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ppocr/modeling/architectures/rec_model.py b/ppocr/modeling/architectures/rec_model.py index d0441c05..9f8c779c 100755 --- a/ppocr/modeling/architectures/rec_model.py +++ b/ppocr/modeling/architectures/rec_model.py @@ -16,6 +16,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from collections import OrderedDict + from paddle import fluid from ppocr.utils.utility import create_module @@ -215,16 +217,15 @@ class RecModel(object): label = labels['label'] if self.loss_type == 'srn': total_loss, img_loss, word_loss = self.loss(predicts, labels) - outputs = { - 'total_loss': total_loss, - 'img_loss': img_loss, - 'word_loss': word_loss, - 'decoded_out': decoded_out, - 'label': label - } + outputs = OrderedDict([('total_loss', total_loss), + ('img_loss', img_loss), + ('word_loss', word_loss), + ('decoded_out', decoded_out), + ('label', label)]) else: - outputs = {'total_loss':loss, 'decoded_out':\ - decoded_out, 'label':label} + outputs = OrderedDict([('total_loss', loss), + ('decoded_out', decoded_out), + ('label', label)]) return loader, outputs # export_model elif mode == "export": @@ -233,16 +234,15 @@ class RecModel(object): predict = fluid.layers.softmax(predict) if self.loss_type == "srn": return [ - image, labels, { - 'decoded_out': decoded_out, - 'predicts': predict - } - ] + image, labels, OrderedDict([('decoded_out', decoded_out), + ('predicts', predict)])] - return [image, {'decoded_out': decoded_out, 'predicts': predict}] + return [image, OrderedDict([('decoded_out', decoded_out), + ('predicts', predict)])] # eval or test else: predict = predicts['predict'] if self.loss_type == "ctc": predict = fluid.layers.softmax(predict) - return loader, {'decoded_out': decoded_out, 'predicts': predict} + return loader, OrderedDict([('decoded_out', decoded_out), + ('predicts', predict)]) \ No newline at end of file -- GitLab