will-jl944 vor 4 Jahren
Ursprung
Commit
0407024ab4

+ 3 - 2
paddlex_restful/restful/app.py

@@ -26,6 +26,7 @@ from . import workspace_pb2 as w
 from .utils import CustomEncoder, ShareData, is_pic, get_logger, TaskStatus, get_ip
 from paddlex_restful.restful.dataset.utils import get_encoding
 import numpy as np
+import pickle
 
 app = Flask(__name__)
 CORS(app, supports_credentials=True)
@@ -570,7 +571,7 @@ def task_evaluate():
                 'result'] is not None:
             if 'Confusion_Matrix' in ret['result']:
                 ret['result']['Confusion_Matrix'] = ret['result'][
-                    'Confusion_Matrix'].tolist()
+                    'Confusion_Matrix']
             ret['result'] = CustomEncoder().encode(ret['result'])
             ret['result'] = json.loads(ret['result'])
         ret['evaluate_status'] = ret['evaluate_status'].value
@@ -590,7 +591,7 @@ def task_evaluate_file():
             assert os.path.abspath(ret).startswith(
                 os.path.abspath(SD.workspace_dir)
             ) and ".." not in ret, "Illegal path {}.".format(ret)
-            return send_file(ret)
+            return pickle.load(open(os.path.abspath(ret), 'rb'))
         else:
             from .project.task import get_evaluate_result
             from .project.task import import_evaluate_excel

+ 3 - 2
paddlex_restful/restful/project/evaluate/detection.py

@@ -606,7 +606,8 @@ class DetEvaluator(object):
         '''生成评估报告。
         '''
         report = dict()
-        report['Confusion_Matrix'] = copy.deepcopy(self.cal_confusion_matrix())
+        report['Confusion_Matrix'] = copy.deepcopy(self.cal_confusion_matrix()
+                                                   .tolist())
         report['mAP'] = copy.deepcopy(self.cal_map())
         report['PRAP'] = copy.deepcopy(self.cal_precision_recall())
         report['label_list'] = copy.deepcopy(list(self.cname2cid.keys()))
@@ -779,7 +780,7 @@ class InsSegEvaluator(DetEvaluator):
             report['BBox_PRAP'][k]['AP'] = v
 
         report['Mask_Confusion_Matrix'] = copy.deepcopy(
-            self.cal_confusion_matrix_mask())
+            self.cal_confusion_matrix_mask().tolist())
         report['Mask_mAP'] = copy.deepcopy(self.cal_map_mask())
         report['Mask_PRAP'] = copy.deepcopy(self.cal_precision_recall_mask())
         per_ap_mask = copy.deepcopy(self.cal_ap_mask())