Repository: PaddlePaddle/models

Issue:
ocr_recognition 评估、预测错误
1、ocr_recognition CTC model eval.py有函数缺少参数：
<img width="909" alt="e8ec154b99d031a872f8f222e1088e92" src="https://user-images.githubusercontent.com/46314656/53880163-453f1e00-404b-11e9-85c7-8dd84fe81020.png">
2、预测时CTC和attention模型的报错：
<img width="987" alt="93b4cc1a5a0309688355e42a33bddad7" src="https://user-images.githubusercontent.com/46314656/53880294-9e0eb680-404b-11e9-9619-47c6bdaff889.png">



Discussion:
https://github.com/PaddlePaddle/models/commit/c765794e0d8bd9e2f93a29962de89560ca1506be#diff-366b354acb1f3c3a449809e462657458R209
下载的是最新版本的models，运行python eval.py 报错信息如下：
![image](https://user-images.githubusercontent.com/37854899/54268250-c2bbde80-45b5-11e9-9c32-133e75759c99.png)
使用文档中提供的ocr_attention_params进行infer报错信息如下：
![image](https://user-images.githubusercontent.com/37854899/54268332-ee3ec900-45b5-11e9-8240-0083a142806c.png)
使用ocr_ctc_params进行infer正确。
1.attention模型eval报错：
<img width="835" alt="b9efa348f566a44a527fa99d7b50d100" src="https://user-images.githubusercontent.com/46314656/56134632-9551be80-5fc1-11e9-9fe0-1cbb65cf7cc7.png">
2.attention模型infer报错：
Traceback (most recent call last):
  File "infer.py", line 153, in <module>
    main()
  File "infer.py", line 149, in main
    inference(args)
  File "infer.py", line 81, in inference
    feed_dict = get_feeder_data(data, place, need_label=False)
TypeError: get_attention_feeder_for_infer() got an unexpected keyword argument 'need_label'

Resolving patch:
diff --git a/PaddleCV/ocr_recognition/infer.py b/PaddleCV/ocr_recognition/infer.py
--- a/PaddleCV/ocr_recognition/infer.py
+++ b/PaddleCV/ocr_recognition/infer.py
@@ -31,7 +31,7 @@ def inference(args):
     """OCR inference"""
     if args.model == "crnn_ctc":
         infer = ctc_infer
-        get_feeder_data = get_ctc_feeder_data
+        get_feeder_data = get_ctc_feeder_for_infer
     else:
         infer = attention_infer
         get_feeder_data = get_attention_feeder_for_infer
@@ -78,7 +78,7 @@ def inference(args):
     batch_times = []
     iters = 0
     for data in infer_reader():
-        feed_dict = get_feeder_data(data, place, need_label=False)
+        feed_dict = get_feeder_data(data, place)
         if args.iterations > 0 and iters == args.iterations + args.skip_batch_num:
             break
         if iters < args.skip_batch_num:
diff --git a/PaddleCV/ocr_recognition/utility.py b/PaddleCV/ocr_recognition/utility.py
--- a/PaddleCV/ocr_recognition/utility.py
+++ b/PaddleCV/ocr_recognition/utility.py
@@ -83,7 +83,8 @@ def get_ctc_feeder_data(data, place, need_label=True):
     pixel_tensor = core.LoDTensor()
     pixel_data = None
     pixel_data = np.concatenate(
-        list(map(lambda x: x[0][np.newaxis, :], data)), axis=0).astype("float32")
+        list(map(lambda x: x[0][np.newaxis, :], data)),
+        axis=0).astype("float32")
     pixel_tensor.set(pixel_data, place)
     label_tensor = to_lodtensor(list(map(lambda x: x[1], data)), place)
     if need_label:
@@ -92,11 +93,16 @@ def get_ctc_feeder_data(data, place, need_label=True):
         return {"pixel": pixel_tensor}
 
 
+def get_ctc_feeder_for_infer(data, place):
+    return get_ctc_feeder_data(data, place, need_label=False)
+
+
 def get_attention_feeder_data(data, place, need_label=True):
     pixel_tensor = core.LoDTensor()
     pixel_data = None
     pixel_data = np.concatenate(
-        list(map(lambda x: x[0][np.newaxis, :], data)), axis=0).astype("float32")
+        list(map(lambda x: x[0][np.newaxis, :], data)),
+        axis=0).astype("float32")
     pixel_tensor.set(pixel_data, place)
     label_in_tensor = to_lodtensor(list(map(lambda x: x[1], data)), place)
     label_out_tensor = to_lodtensor(list(map(lambda x: x[2], data)), place)
@@ -127,7 +133,8 @@ def get_attention_feeder_for_infer(data, place):
     pixel_tensor = core.LoDTensor()
     pixel_data = None
     pixel_data = np.concatenate(
-        list(map(lambda x: x[0][np.newaxis, :], data)), axis=0).astype("float32")
+        list(map(lambda x: x[0][np.newaxis, :], data)),
+        axis=0).astype("float32")
     pixel_tensor.set(pixel_data, place)
     return {
         "pixel": pixel_tensor,


Test patch: