提交 27347336 编写于 作者: F FLming

Fix bug: Errors caused by disordered dictionary

上级 5238c0bd
...@@ -16,6 +16,8 @@ from __future__ import absolute_import ...@@ -16,6 +16,8 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
from collections import OrderedDict
from paddle import fluid from paddle import fluid
from ppocr.utils.utility import create_module from ppocr.utils.utility import create_module
...@@ -215,16 +217,15 @@ class RecModel(object): ...@@ -215,16 +217,15 @@ class RecModel(object):
label = labels['label'] label = labels['label']
if self.loss_type == 'srn': if self.loss_type == 'srn':
total_loss, img_loss, word_loss = self.loss(predicts, labels) total_loss, img_loss, word_loss = self.loss(predicts, labels)
outputs = { outputs = OrderedDict([('total_loss', total_loss),
'total_loss': total_loss, ('img_loss', img_loss),
'img_loss': img_loss, ('word_loss', word_loss),
'word_loss': word_loss, ('decoded_out', decoded_out),
'decoded_out': decoded_out, ('label', label)])
'label': label
}
else: else:
outputs = {'total_loss':loss, 'decoded_out':\ outputs = OrderedDict([('total_loss', loss),
decoded_out, 'label':label} ('decoded_out', decoded_out),
('label', label)])
return loader, outputs return loader, outputs
# export_model # export_model
elif mode == "export": elif mode == "export":
...@@ -233,16 +234,15 @@ class RecModel(object): ...@@ -233,16 +234,15 @@ class RecModel(object):
predict = fluid.layers.softmax(predict) predict = fluid.layers.softmax(predict)
if self.loss_type == "srn": if self.loss_type == "srn":
return [ return [
image, labels, { image, labels, OrderedDict([('decoded_out', decoded_out),
'decoded_out': decoded_out, ('predicts', predict)])]
'predicts': predict
}
]
return [image, {'decoded_out': decoded_out, 'predicts': predict}] return [image, OrderedDict([('decoded_out', decoded_out),
('predicts', predict)])]
# eval or test # eval or test
else: else:
predict = predicts['predict'] predict = predicts['predict']
if self.loss_type == "ctc": if self.loss_type == "ctc":
predict = fluid.layers.softmax(predict) 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册