Przeglądaj źródła

1.iou判定修改;选择推断中聚类方法改进;
2.选择题题号问题修改;
3.其他题号识别问题,ubuntu加如tr-ocr;
4.模型存放位置修改,方便以后替换。

lighttxu 4 lat temu
rodzic
commit
a6a8389b39

+ 1 - 1
.gitignore

@@ -62,4 +62,4 @@ segment/sheet_resolve/model
 # upload images
 segment/exam_image
 # db
-.sqlite3
+*.sqlite3

BIN
db.sqlite3


+ 12 - 4
segment/server.py

@@ -6,7 +6,7 @@ import uuid
 import shutil
 import xml.etree.cElementTree as ET
 from urllib import parse, request
-
+from io import BytesIO
 import cv2
 import numpy as np
 import pypinyin
@@ -45,9 +45,17 @@ def convert_pil_to_jpeg(raw_img):
     return img, open_cv_image
 
 
-def opencv2base64(img):
-    image = cv2.imencode('.jpg', img)[1]
-    base64_data = str(base64.b64encode(image))[2:-1]
+def opencv2base64(image, to_pil=True):
+    # image = cv2.imencode('.jpg', img)[1]
+    # base64_data = str(base64.b64encode(image))[2:-1]
+
+    if to_pil:
+        image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
+    output_buffer = BytesIO()
+    image.save(output_buffer, format='JPEG')
+    byte_data = output_buffer.getvalue()
+    base64_data = base64.b64encode(byte_data)
+
     return base64_data
 
 

+ 54 - 23
segment/sheet_resolve/analysis/choice/choice_line_box.py

@@ -4,6 +4,7 @@
 import time
 import re
 import cv2, os
+import traceback
 import numpy as np
 import xml.etree.cElementTree as ET
 from segment.sheet_resolve.tools.brain_api import get_ocr_text_and_coordinate
@@ -471,40 +472,70 @@ def choice_m_row_col(image, choice_m_bbox_list, xml_path):
 
         x_y_interval_all = []
         s_box_w_h = []
-        for index, s_box in enumerate(choice_m_box_dict):
-            all_small_coordinate_dict = s_box['all_small_coordinate']
-            all_small_coordinate_list = [[ele['xmin'], ele['ymin'], ele['xmax'], ele['ymax']] for ele in all_small_coordinate_dict]
-            col = s_box['cols']
-            x_y_interval = utils.get_x_diff_and_y_diff1(all_small_coordinate_list, col)
+        rows_list = [ele['rows'] for ele in choice_m_box_dict if ele['rows'] == 1]
+        if len(rows_list) == len(choice_m_box_dict):
+            w_list = [ele['single_width'] for ele in choice_m_box_dict]
+            h_list = [ele['single_height'] for ele in choice_m_box_dict]
+            w_arr = np.array(w_list)
+            h_arr = np.array(h_list)
+            s_box_w_h.append((int(np.mean(w_arr)), int(np.mean(h_arr))))
+
+            x_y_interval = s_box_w_h
             x_y_interval_all.append(x_y_interval)
 
-            all_small_coordinate_list = sorted(all_small_coordinate_list, key=lambda k: k[1])
-            s_box_array = np.array(all_small_coordinate_list)
-            s_box_wid_hei = (
-                int(np.mean(s_box_array[:, 2])) - int(np.mean(s_box_array[:, 0])),
-                int(np.mean(s_box_array[:, 3])) - int(np.mean(s_box_array[:, 1])))
-            s_box_w_h.append(s_box_wid_hei)
+        else:
+            for index, s_box in enumerate(choice_m_box_dict):
+                all_small_coordinate_dict = s_box['all_small_coordinate']
+                all_small_coordinate_list = [[ele['xmin'], ele['ymin'], ele['xmax'], ele['ymax']] for ele in all_small_coordinate_dict]
+                col = s_box['cols']
+                rows = s_box['rows']
+                if rows == 1:
+                    continue
+                else:
+                    x_y_interval = utils.get_x_diff_and_y_diff1(all_small_coordinate_list, col)
+                    x_y_interval_all.append(x_y_interval)
+
+                    all_small_coordinate_list = sorted(all_small_coordinate_list, key=lambda k: k[1])
+                    s_box_array = np.array(all_small_coordinate_list)
+                    s_box_wid_hei = (
+                        int(np.mean(s_box_array[:, 2])) - int(np.mean(s_box_array[:, 0])),
+                        int(np.mean(s_box_array[:, 3])) - int(np.mean(s_box_array[:, 1])))
+                    s_box_w_h.append(s_box_wid_hei)
         x_y_interval_arr = np.array(x_y_interval_all)
-        x_y_interval_ave = (int(np.mean(x_y_interval_arr[:, 0])), int(np.mean(x_y_interval_arr[:, 1])))
+        if len(x_y_interval_arr) == 1:
+
+            x_y_interval_ave = x_y_interval_all[0][0]
+            singe_box_width_height_ave = s_box_w_h[0]
 
-        s_box_w_h_arr = np.array(s_box_w_h)
-        singe_box_width_height_ave = (int(np.mean(s_box_w_h_arr[:, 0])), int(np.mean(s_box_w_h_arr[:, 1])))
+            image_height, image_width, _ = image.shape
+            image_size = (image_width, image_height)
+        else:
+            x_y_interval_ave = (int(np.mean(x_y_interval_arr[:, 0])), int(np.mean(x_y_interval_arr[:, 1])))
+
+            s_box_w_h_arr = np.array(s_box_w_h)
+            singe_box_width_height_ave = (int(np.mean(s_box_w_h_arr[:, 0])), int(np.mean(s_box_w_h_arr[:, 1])))
 
-        image_height, image_width, _ = image.shape
-        image_size = (image_width, image_height)
+            image_height, image_width, _ = image.shape
+            image_size = (image_width, image_height)
         choice_bbox = choice_bbox_vague(choice_m_list, x_y_interval_ave, singe_box_width_height_ave, direction, image_size)
-        choice_m_dict_list_all = []
-        choice_m_dict_list_part1 = []
+        choice_m_dict_list_all_tmp = []
         for index, choice_box_ele in enumerate(choice_bbox):
             choice_region = utils.crop_region_direct(image, choice_box_ele[0])
-            # choice_path = xml_path[: xml_path.rfind('\\')]
-            # cv2.imwrite(os.path.join(choice_path, 'choice_region_' + str(index) + '.jpg'), choice_region)
+            choice_path = xml_path[: xml_path.rfind('\\')]
+            cv2.imwrite(os.path.join(choice_path, 'choice_region_' + str(index) + '.jpg'), choice_region)
             choice_m_box_dict_new = [choice_m_box_dict[i] for i in choice_box_ele[1]]
             choice_m_dict_list_part = get_title_number_by_choice_m.get_title_number(choice_box_ele[0], choice_region,
-                                                                                    choice_m_box_dict_new, direction)
-            choice_m_dict_list_part1.append(choice_m_dict_list_part)
-        choice_m_dict_list_all = choice_m_dict_list_part1[0] + choice_m_dict_list_part1[1]
+                                                                                     choice_m_box_dict_new, direction)
+            choice_m_dict_list_all_tmp.append(choice_m_dict_list_part)
+        if len(choice_m_dict_list_all_tmp) == 1:
+            choice_m_dict_list_all = choice_m_dict_list_all_tmp[0]
+        else:
+            choice_m_dict_list_all = []
+            for i in choice_m_dict_list_all_tmp:
+                choice_m_dict_list_all = choice_m_dict_list_all + i
     except Exception as e:
+        print(e)
+        traceback.print_exc()
         choice_m_dict_list_all = choice_m_dict_list
 
     return choice_m_dict_list_all

+ 140 - 109
segment/sheet_resolve/analysis/choice/get_title_number_by_choice_m.py

@@ -193,110 +193,113 @@ def get_one_col_box(all_small_coordinate_list, width):
 def analysis_s_box(choice_m_bbox_list):
     choice_m_box_dict = []
     for index, s_choice_m_dict in enumerate(choice_m_bbox_list):
-        all_small_coordinate_list0 = [[ele['xmin'], ele['ymin'], ele['xmax'], ele['ymax']] for ele in s_choice_m_dict['all_small_coordinate']]
-        all_small_coordinate_raw0 = sorted(all_small_coordinate_list0, key=lambda k: k[1])
-        all_small_coordinate_raw_array0 = np.array(all_small_coordinate_raw0)
-        s_box_wid_hei = (
-            int(np.mean(all_small_coordinate_raw_array0[:, 2])) - int(np.mean(all_small_coordinate_raw_array0[:, 0])),
-            int(np.mean(all_small_coordinate_raw_array0[:, 3])) - int(np.mean(all_small_coordinate_raw_array0[:, 1])))
-
-        all_small_coordinate_list = move_intersect_box(all_small_coordinate_list0)
-
-        all_small_coordinate_raw = sorted(all_small_coordinate_list, key=lambda k: k[1])
-        all_small_coordinate_raw_array = np.array(all_small_coordinate_raw)
-
-        pre = all_small_coordinate_raw_array[1:, 1]
-        rear = all_small_coordinate_raw_array[:-1, 1]
-        y_diff = rear - pre
-        index_list = [index for index, ele in enumerate(y_diff) if ele < 0 and abs(ele) > s_box_wid_hei[1]//3]
-
-        res_list = []
-        split_x_index = [ele + 1 for ele in index_list]
-        split_x_index.insert(0, 0)
-        split_x_index.insert(-1, len(all_small_coordinate_raw))
-        split_x_index = sorted(list(set(split_x_index)))
-        for i, split in enumerate(split_x_index[1:]):
-            one_line = all_small_coordinate_raw[split_x_index[i]:split_x_index[i + 1]]
-            one_line = sorted(one_line, key=lambda k: k[0])
-            res_list.append(one_line)
-
-        one_line_list = []
-        for index1, ele1 in enumerate(res_list):
-            if len(ele1) == s_choice_m_dict['cols']:
-                one_line_list.append(ele1)
-        s_box_all = [ele0 for ele in one_line_list for ele0 in ele]
-        if s_box_all == []:
-            x_y_interval = int((s_choice_m_dict['single_width'] * 2) // 3)
+        if s_choice_m_dict['rows'] == 1:
+            choice_m_box_dict.append(s_choice_m_dict)
         else:
-            x_y_interval = []
-            if len(one_line_list) > 1:
-                x_y_interval = get_x_diff_and_y_diff0(s_box_all)
-            elif len(one_line_list) == 1:
-                s_box_arr = np.array(s_box_all)
-                rear = s_box_arr[1:, 0]
-                pre = s_box_arr[:-1, 2]
-                x_y_interval = int(np.mean(rear - pre))
-            elif len(one_line_list) == []:
-                x_y_interval = get_x_diff_and_y_diff0(all_small_coordinate_raw)
-
-        all_small_coordinate = []
-        res_list = sorted(res_list, key=lambda k: k[0])
-        for index, box_list in enumerate(res_list):
-            for s_box in box_list:
-                all_small_coordinate.append(s_box)
-            if len(box_list) == s_choice_m_dict['cols']:
-                continue
+            all_small_coordinate_list0 = [[ele['xmin'], ele['ymin'], ele['xmax'], ele['ymax']] for ele in s_choice_m_dict['all_small_coordinate']]
+            all_small_coordinate_raw0 = sorted(all_small_coordinate_list0, key=lambda k: k[1])
+            all_small_coordinate_raw_array0 = np.array(all_small_coordinate_raw0)
+            s_box_wid_hei = (
+                int(np.mean(all_small_coordinate_raw_array0[:, 2])) - int(np.mean(all_small_coordinate_raw_array0[:, 0])),
+                int(np.mean(all_small_coordinate_raw_array0[:, 3])) - int(np.mean(all_small_coordinate_raw_array0[:, 1])))
+
+            all_small_coordinate_list = move_intersect_box(all_small_coordinate_list0)
+
+            all_small_coordinate_raw = sorted(all_small_coordinate_list, key=lambda k: k[1])
+            all_small_coordinate_raw_array = np.array(all_small_coordinate_raw)
+
+            pre = all_small_coordinate_raw_array[1:, 1]
+            rear = all_small_coordinate_raw_array[:-1, 1]
+            y_diff = rear - pre
+            index_list = [index for index, ele in enumerate(y_diff) if ele < 0 and abs(ele) > s_box_wid_hei[1]//3]
+
+            res_list = []
+            split_x_index = [ele + 1 for ele in index_list]
+            split_x_index.insert(0, 0)
+            split_x_index.insert(-1, len(all_small_coordinate_raw))
+            split_x_index = sorted(list(set(split_x_index)))
+            for i, split in enumerate(split_x_index[1:]):
+                one_line = all_small_coordinate_raw[split_x_index[i]:split_x_index[i + 1]]
+                one_line = sorted(one_line, key=lambda k: k[0])
+                res_list.append(one_line)
+
+            one_line_list = []
+            for index1, ele1 in enumerate(res_list):
+                if len(ele1) == s_choice_m_dict['cols']:
+                    one_line_list.append(ele1)
+            s_box_all = [ele0 for ele in one_line_list for ele0 in ele]
+            if s_box_all == []:
+                x_y_interval = int((s_choice_m_dict['single_width'] * 2) // 3)
             else:
-                one_line_xmin = [ele[0] for ele in box_list]
-                choice_m_xmin = s_choice_m_dict['bounding_box']['xmin']
-                exist_index_all = []
-                for exist_index, exist_xmin in enumerate(one_line_xmin):
-                    if abs(choice_m_xmin - exist_xmin) <= s_box_wid_hei[0]:
-                        exist_index_all.append(0)
-                    else:
-                        k = round(abs(choice_m_xmin - exist_xmin) / (s_box_wid_hei[0] + x_y_interval))
-                        exist_index_all.append(k)
-
-                s_box_index_all = [ele for ele in range(s_choice_m_dict['cols'])]
-                lack_index = [ele for ele in s_box_index_all if ele not in exist_index_all]
-                if 0 in exist_index_all:
-                    for lack_ele in lack_index:
-                        xmin = box_list[0][0] + lack_ele * (s_box_wid_hei[0] + x_y_interval)
-                        ymin = box_list[0][1]
-                        xmax = xmin + s_box_wid_hei[0]
-                        ymax = box_list[0][3]
-                        all_small_coordinate.append([xmin, ymin, xmax, ymax])
-                elif (s_choice_m_dict['cols'] - 1) in exist_index_all:
-                    for lack_ele in lack_index:
-                        xmin = box_list[-1][0] - (s_choice_m_dict['cols'] - 1 - lack_ele) * (s_box_wid_hei[0] + x_y_interval)
-                        ymin = box_list[-1][1]
-                        xmax = xmin + s_box_wid_hei[0]
-                        ymax = box_list[-1][3]
-                        all_small_coordinate.append([xmin, ymin, xmax, ymax])
-                elif 1 in exist_index_all:
-                    for lack_ele in lack_index:
-                        if lack_ele < 1:
-                            xmin = box_list[0][0] - (s_box_wid_hei[0] + x_y_interval)
+                x_y_interval = []
+                if len(one_line_list) > 1:
+                    x_y_interval = get_x_diff_and_y_diff0(s_box_all)
+                elif len(one_line_list) == 1:
+                    s_box_arr = np.array(s_box_all)
+                    rear = s_box_arr[1:, 0]
+                    pre = s_box_arr[:-1, 2]
+                    x_y_interval = int(np.mean(rear - pre))
+                elif len(one_line_list) == []:
+                    x_y_interval = get_x_diff_and_y_diff0(all_small_coordinate_raw)
+
+            all_small_coordinate = []
+            res_list = sorted(res_list, key=lambda k: k[0])
+            for index, box_list in enumerate(res_list):
+                for s_box in box_list:
+                    all_small_coordinate.append(s_box)
+                if len(box_list) == s_choice_m_dict['cols']:
+                    continue
+                else:
+                    one_line_xmin = [ele[0] for ele in box_list]
+                    choice_m_xmin = s_choice_m_dict['bounding_box']['xmin']
+                    exist_index_all = []
+                    for exist_index, exist_xmin in enumerate(one_line_xmin):
+                        if abs(choice_m_xmin - exist_xmin) <= s_box_wid_hei[0]:
+                            exist_index_all.append(0)
+                        else:
+                            k = round(abs(choice_m_xmin - exist_xmin) / (s_box_wid_hei[0] + x_y_interval))
+                            exist_index_all.append(k)
+
+                    s_box_index_all = [ele for ele in range(s_choice_m_dict['cols'])]
+                    lack_index = [ele for ele in s_box_index_all if ele not in exist_index_all]
+                    if 0 in exist_index_all:
+                        for lack_ele in lack_index:
+                            xmin = box_list[0][0] + lack_ele * (s_box_wid_hei[0] + x_y_interval)
                             ymin = box_list[0][1]
                             xmax = xmin + s_box_wid_hei[0]
                             ymax = box_list[0][3]
                             all_small_coordinate.append([xmin, ymin, xmax, ymax])
-                        else:
-                            xmin = box_list[0][0] + (lack_ele - 1) * (s_box_wid_hei[0] + x_y_interval)
-                            ymin = box_list[0][1]
+                    elif (s_choice_m_dict['cols'] - 1) in exist_index_all:
+                        for lack_ele in lack_index:
+                            xmin = box_list[-1][0] - (s_choice_m_dict['cols'] - 1 - lack_ele) * (s_box_wid_hei[0] + x_y_interval)
+                            ymin = box_list[-1][1]
                             xmax = xmin + s_box_wid_hei[0]
-                            ymax = box_list[0][3]
+                            ymax = box_list[-1][3]
                             all_small_coordinate.append([xmin, ymin, xmax, ymax])
-        all_small_coordinate0 = []
-        for s_bbox in all_small_coordinate:
-            location = {}
-            location['xmin'] = s_bbox[0]
-            location['ymin'] = s_bbox[1]
-            location['xmax'] = s_bbox[2]
-            location['ymax'] = s_bbox[3]
-            all_small_coordinate0.append(location)
-        s_choice_m_dict.update({'all_small_coordinate': all_small_coordinate0})
-        choice_m_box_dict.append(s_choice_m_dict)
+                    elif 1 in exist_index_all:
+                        for lack_ele in lack_index:
+                            if lack_ele < 1:
+                                xmin = box_list[0][0] - (s_box_wid_hei[0] + x_y_interval)
+                                ymin = box_list[0][1]
+                                xmax = xmin + s_box_wid_hei[0]
+                                ymax = box_list[0][3]
+                                all_small_coordinate.append([xmin, ymin, xmax, ymax])
+                            else:
+                                xmin = box_list[0][0] + (lack_ele - 1) * (s_box_wid_hei[0] + x_y_interval)
+                                ymin = box_list[0][1]
+                                xmax = xmin + s_box_wid_hei[0]
+                                ymax = box_list[0][3]
+                                all_small_coordinate.append([xmin, ymin, xmax, ymax])
+            all_small_coordinate0 = []
+            for s_bbox in all_small_coordinate:
+                location = {}
+                location['xmin'] = s_bbox[0]
+                location['ymin'] = s_bbox[1]
+                location['xmax'] = s_bbox[2]
+                location['ymax'] = s_bbox[3]
+                all_small_coordinate0.append(location)
+            s_choice_m_dict.update({'all_small_coordinate': all_small_coordinate0})
+            choice_m_box_dict.append(s_choice_m_dict)
     return choice_m_box_dict
 
 
@@ -374,20 +377,49 @@ def get_title_number(choice_bbox, choice_region, choice_m_box_dict, direction):
             s_bbox_new = utils.get_img_region_box1(s_bbox, choice_bbox)
             all_small_coordinate_new.append(s_bbox_new)
         col = s_choice_m_box['cols']
-        x_y_interval = utils.get_x_diff_and_y_diff1(all_small_coordinate_new, col)
-        x_y_interval_all.append(x_y_interval)
+        rows = s_choice_m_box['rows']
+        rows_list = [ele['rows'] for ele in choice_m_box_dict if ele['rows'] == 1]
+        if len(rows_list) == len(choice_m_box_dict):
+            w_list = [ele['single_width'] for ele in choice_m_box_dict]
+            h_list = [ele['single_height'] for ele in choice_m_box_dict]
+            w_arr = np.array(w_list)
+            h_arr = np.array(h_list)
+            s_box_wid_hei = ((int(np.mean(w_arr)), int(np.mean(h_arr))))
+            s_box_w_h.append(s_box_wid_hei)
+            x_y_interval = s_box_wid_hei
+            x_y_interval_all.append(x_y_interval)
+            s_choice_m_box.update({'bounding_box': choice_m_new_box,
+                                   'all_small_coordinate': all_small_coordinate_new,
+                                   's_box_w_h': s_box_wid_hei,
+                                   'x_y_interval': x_y_interval})
+            choice_m_box_dict_new.append(s_choice_m_box)
+        else:
+            if rows == 1:
+                all_small_coordinate_list = sorted(all_small_coordinate_new, key=lambda k: k[1])
+                s_box_array = np.array(all_small_coordinate_list)
+                s_box_wid_hei = (int(np.mean(s_box_array[:, 2])) - int(np.mean(s_box_array[:, 0])),
+                                 int(np.mean(s_box_array[:, 3])) - int(np.mean(s_box_array[:, 1])))
+                s_box_w_h.append(s_box_wid_hei)
+                s_choice_m_box.update({'bounding_box': choice_m_new_box,
+                                       'all_small_coordinate': all_small_coordinate_new,
+                                       's_box_w_h': s_box_wid_hei,
+                                       'x_y_interval': ('nan', 'nan')})
+                choice_m_box_dict_new.append(s_choice_m_box)
+            else:
+                x_y_interval = utils.get_x_diff_and_y_diff1(all_small_coordinate_new, col)
+                x_y_interval_all.append(x_y_interval)
 
-        all_small_coordinate_list = sorted(all_small_coordinate_new, key=lambda k: k[1])
-        s_box_array = np.array(all_small_coordinate_list)
-        s_box_wid_hei = (int(np.mean(s_box_array[:, 2])) - int(np.mean(s_box_array[:, 0])),
-                         int(np.mean(s_box_array[:, 3])) - int(np.mean(s_box_array[:, 1])))
-        s_box_w_h.append(s_box_wid_hei)
-        s_choice_m_box.update({'bounding_box': choice_m_new_box,
-                               'all_small_coordinate': all_small_coordinate_new,
-                               's_box_w_h': s_box_wid_hei,
-                               'x_y_interval': x_y_interval})
+                all_small_coordinate_list = sorted(all_small_coordinate_new, key=lambda k: k[1])
+                s_box_array = np.array(all_small_coordinate_list)
+                s_box_wid_hei = (int(np.mean(s_box_array[:, 2])) - int(np.mean(s_box_array[:, 0])),
+                                 int(np.mean(s_box_array[:, 3])) - int(np.mean(s_box_array[:, 1])))
+                s_box_w_h.append(s_box_wid_hei)
+                s_choice_m_box.update({'bounding_box': choice_m_new_box,
+                                       'all_small_coordinate': all_small_coordinate_new,
+                                       's_box_w_h': s_box_wid_hei,
+                                       'x_y_interval': x_y_interval})
 
-        choice_m_box_dict_new.append(s_choice_m_box)
+                choice_m_box_dict_new.append(s_choice_m_box)
 
     x_y_interval_arr = np.array(x_y_interval_all)
     x_y_interval_ave = (int(np.mean(x_y_interval_arr[:, 0])), int(np.mean(x_y_interval_arr[:, 1])))
@@ -435,7 +467,6 @@ def get_title_number(choice_bbox, choice_region, choice_m_box_dict, direction):
         # if direction == 180:     # 题号vertical
         row_and_col = (choice_m_s['rows'], choice_m_s['cols'])
         title_number = choice_m_s['title_number']
-        x_y_interval = choice_m_s['x_y_interval']
         single_bbox_width_height = choice_m_s['s_box_w_h']
         s_box = choice_m_s['all_small_coordinate']
         if len(title_number) == row_and_col[0]:

+ 5 - 3
segment/sheet_resolve/analysis/resolve.py

@@ -32,7 +32,7 @@ logger = logging.getLogger(settings.LOGGING_TYPE)
 sheet_infer_dict = dict(bar_code=True,
                         choice_m=True,
                         exam_number=True,
-                        common_sheet=True)
+                        common_sheet=False)
 infer_choice_m_flag = False
 
 
@@ -77,7 +77,8 @@ def sheet(series_number, image_path, image, conf_thresh, mns_thresh, subject, sh
             cond3 = 'exam_number_w' in fetched_class
             cond4 = 'exam_number_s' in fetched_class
 
-            if cond1 and cond3 and not cond4:
+            # if cond1 and cond3 and not cond4:
+            if cond1 and cond3:
                 regions = adjust_exam_number(regions)
             if not cond1 and cond4:
                 exam_number_list = exam_number_infer_by_s(image, regions)
@@ -105,7 +106,8 @@ def sheet(series_number, image_path, image, conf_thresh, mns_thresh, subject, sh
                         tf_loc = tf_box['bounding_box']
                         iou = utils.cal_iou(infer_loc, tf_loc)
                         # if iou[0] > 0.70 or iou[1] > 0.70 or iou[2] > 0.70:
-                        if iou[0] > 0.70 or iou[2] > 0.70:
+                        # if iou[0] > 0.70 or iou[2] > 0.70:
+                        if iou[0] > 0.85:
                             # if infer_box not in remain_choice_m:
                             #     remain_choice_m.append(infer_box)
                             #     choice_m_list.remove(infer_box)

+ 2 - 1
segment/sheet_resolve/analysis/sheet/choice_infer.py

@@ -229,6 +229,7 @@ def cluster2choice_m(cluster_list, mean_width):
                 numbers_array[suspect] = -1
 
         numbers_array = infer_number(numbers_array, number_interval_mode_value)  # 推断题号
+        numbers_array = np.array(numbers_array)
 
     numbers_interval = np.abs(numbers_array[1:] - numbers_array[:-1])
 
@@ -271,7 +272,7 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
     else:
         eps = int(mean_height * 3)
     print("eps: ", eps)
-    db = DBSCAN(eps=eps, min_samples=1, metric='chebyshev').fit(arr)
+    db = DBSCAN(eps=eps, min_samples=2, metric='chebyshev').fit(arr)
 
     labels = db.labels_
     # print(labels)

+ 162 - 108
segment/sheet_resolve/analysis/sheet/ocr_key_words.py

@@ -1,10 +1,11 @@
 # -*- coding: utf-8 -*-
-# @Time : 2020/5/14 0014 13:37
+# @Time : 2020/5/22 0022 17:04
 # @Author : LF
-# @FileName: ocr_key_words_2020_5_14.py
+# @FileName: ocr_key_words.py
 # @Software: PyCharm
-
 import re
+
+
 def find_repeat(source, elmt):  # 去重后重新定位数字索引
     elmt_index = []
     s_index = 0
@@ -19,7 +20,7 @@ def find_repeat(source, elmt):  # 去重后重新定位数字索引
     return elmt_index
 
 
-def ocr_key_words(rect,type_score_dict):  # 将ocr识别得到的文字与模型得到的type_score对应
+def ocr_key_words(rect, type_score_dict):  # 将ocr识别得到的文字与模型得到的type_score对应
     '''
     :param rect: OCR识别结果数组,格式:res = {'chars': [},'coordinates': [(),()},'words': []}
     :param type_score_dict: 模型得到的type_score(与模型得到的边框相对应)
@@ -30,19 +31,20 @@ def ocr_key_words(rect,type_score_dict):  # 将ocr识别得到的文字与模型
     ymin = type_score_dict['type_box'][1]
     xmax = type_score_dict['type_box'][2]
     ymax = type_score_dict['type_box'][3]
-    words=[]
+    words = []
 
     for j in range(len_ocr):
-        if rect['coordinates'][j][0] - xmin > -30 and rect['coordinates'][j][1] - ymin > -30 and rect['coordinates'][j][2] - xmax < 30 and rect['coordinates'][j][3] - ymax < 30:
+        if rect['coordinates'][j][0] - xmin > -30 and rect['coordinates'][j][1] - ymin > -30 and rect['coordinates'][j][
+            2] - xmax < 30 and rect['coordinates'][j][3] - ymax < 30:
             word = rect['chars'][j]
             words.append(word)
-    type_score_dict['words']= words
+    type_score_dict['words'] = words
     type_score_dict_ocr = type_score_dict
 
     return type_score_dict_ocr
 
 
-def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
+def key_words(type_score_dict_ocr, type_score_flag):  # 根据OCR结果结合关键字解析
 
     total_score = 0
     volume_score = 0
@@ -53,52 +55,82 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
     all_structure = {}
     keyword_volume = re.compile(r'第卷|第部')
     keyword_type = re.compile(r'选择|非选择题|综合题|问答题|主观题|客观题|解答题|计算题')
-    keyword_type1 = ['选择', '非选择题', '综合题', '问答题', '主观题', '客观题', '解答题','计算题']
+    keyword_type1 = ['选择', '非选择题', '综合题', '问答题', '主观题', '客观题', '解答题', '计算题']
     len_keyword_type1 = len(keyword_type1)
     keyword_item1 = re.compile(r'共分|合计分|总共分|总计分|小题满分|本小题|满分|共计|共.分|合计.分|总共.分|总计.分|小题满分.|本小题.|满分.|共计.')
-    keyword_item2 = re.compile(r'每题分|每小题分|空分|每小题.分|每题.分|空.分')  # '分/题'暂未考虑
+    keyword_item2 = re.compile(r'每题分|每小题分|空分|每小题.分|每题.分|空.分|个分')  # '分/题'暂未考虑
     keyword_item3 = re.compile(r'共题|共小题|分小题|本题小题|共个小题|分为小题|分个小题|本大题共小题')
     keyword_item4 = ['分']
-    keyword_item5 = re.compile(r'分/题|题|.|、')
+    keyword_item5 = re.compile(r'题|.|、')
+    keyword_item6 = re.compile(r'分/题|分')
 
     ocr_1 = type_score_dict_ocr['words']
     s = ''.join((str(x) for x in ocr_1))  # 合并为一个字符串
-    if s.find('IV') != -1 or s.find('Ⅳ') != -1:
+    if s.find('IV') != -1 or s.find('Ⅳ') != -1 or s.find('四') != -1:
         s = s.replace('Ⅳ', '4')
         s = s.replace('IV', '4')
-    elif s.find('III') != -1 or s.find('Ⅲ') != -1:
+        s = s.replace('四', '4')
+    elif s.find('III') != -1 or s.find('Ⅲ') != -1 or s.find('三') != -1:
         s = s.replace('Ⅲ', '3')
         s = s.replace('III', '3')
-    elif s.find('II') != -1 or s.find('Ⅱ') != -1:
+        s = s.replace('三', '3')
+    elif s.find('II') != -1 or s.find('Ⅱ') != -1 or s.find('二') != -1:
         s = s.replace('Ⅱ', '2')
         s = s.replace('II', '2')
-    elif s.find('VI') != -1 or s.find('Ⅵ') != -1:
+        s = s.replace('二', '2')
+    elif s.find('VI') != -1 or s.find('Ⅵ') != -1 or s.find('六') != -1:
         s = s.replace('Ⅵ', '6')
         s = s.replace('VI', '6')
-    elif s.find('VII') != -1 or s.find('Ⅶ') != -1:
+        s = s.replace('六', '6')
+    elif s.find('VII') != -1 or s.find('Ⅶ') != -1 or s.find('七') != -1:
         s = s.replace('Ⅶ', '7')
         s = s.replace('VII', '7')
-    elif s.find('VIII') != -1 or s.find('Ⅷ') != -1:
+        s = s.replace('七', '7')
+    elif s.find('VIII') != -1 or s.find('Ⅷ') != -1 or s.find('八') != -1:
         s = s.replace('Ⅷ', '8')
         s = s.replace('VIII', '8')
-    elif s.find('IX') != -1 or s.find('Ⅸ') != -1:
+        s = s.replace('八', '8')
+    elif s.find('IX') != -1 or s.find('Ⅸ') != -1 or s.find('九') != -1:
         s = s.replace('Ⅸ', '9')
         s = s.replace('IX', '9')
-    elif s.find('X') != -1 or s.find('Ⅹ') != -1:
+        s = s.replace('九', '9')
+    elif s.find('X') != -1 or s.find('Ⅹ') != -1 or s.find('十') != -1:
         s = s.replace('Ⅹ', '10')
         s = s.replace('X', '10')
-    elif s.find('I') != -1 or s.find('Ⅰ') != -1:
+        s = s.replace('十', '10')
+    elif s.find('I') != -1 or s.find('Ⅰ') != -1 or s.find('一') != -1:
         s = s.replace('Ⅰ', '1')
         s = s.replace('I', '1')
-    elif s.find('V') != -1 or s.find('Ⅴ') != -1:
+        s = s.replace('一', '1')
+    elif s.find('V') != -1 or s.find('Ⅴ') != -1 or s.find('五') != -1:
         s = s.replace('Ⅴ', '5')
         s = s.replace('V', '5')
+        s = s.replace('五', '5')
 
     C_s = re.sub("[A-Za-z0-9\!\%\[\]\,\。]", "", s)  # 提取汉字
     E_s = ''.join(re.findall(r'[A-Za-z]', s))  # 提取英文字符
     N_s = re.findall('\d+', s)  # 提取阿拉伯数字
 
-    if len(N_s) == 1 and len(N_s[0]) < 6 and len(E_s) == 0 and (keyword_item5.search(C_s) or len(C_s) == 0):
+    if len(N_s) == 1 and len(N_s[0]) < 6 and len(E_s) == 0 and (keyword_item6.search(C_s)):
+        type_score_dict_ocr['item_N'] = -1
+        type_score_dict_ocr['item_total_score'] = int(N_s[0])
+        type_score_dict_ocr['item_count'] = -1
+        type_score_dict_ocr['item_score'] = -1
+        Score_structure_item = type_score_dict_ocr
+        Score_structure.append(Score_structure_item)
+        all_structure = {'volume_structure': -1,
+                         'Score_structure': Score_structure}
+    elif type_score_flag == 1 and len(N_s) == 1 and len(N_s[0]) < 6 and len(E_s) == 0 and (
+            keyword_item5.search(C_s) or len(C_s) == 0):
+        type_score_dict_ocr['item_N'] = int(N_s[0])
+        type_score_dict_ocr['item_total_score'] = -1
+        type_score_dict_ocr['item_count'] = -1
+        type_score_dict_ocr['item_score'] = -1
+        Score_structure_item = type_score_dict_ocr
+        Score_structure.append(Score_structure_item)
+        all_structure = {'volume_structure': -1,
+                         'Score_structure': Score_structure}
+    elif type_score_flag == 0 and len(N_s) == 1 and len(E_s) == 0 and (keyword_item5.search(C_s)):
         type_score_dict_ocr['item_N'] = int(N_s[0])
         type_score_dict_ocr['item_total_score'] = -1
         type_score_dict_ocr['item_count'] = -1
@@ -151,7 +183,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                 if keyword_item1.search(C_s):
                     if keyword_item2.search(C_s):
                         if num_back0 == '分' and num_back1 == '分':
-                            if N_s[0] < N_s[1]: # 第卷,每小题*分,共*分
+                            if N_s[0] < N_s[1]:  # 第卷,每小题*分,共*分
                                 volume_score = N_s[1]
                                 item_score = N_s[0]
                                 item_count = int(volume_score / item_score)
@@ -272,7 +304,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     volume_score = N_s[0]
                                     item_count = N_s[2]
                                     item_score = N_s[1]
-                                else:               # 第卷,每题*分,共*分,共*题
+                                else:  # 第卷,每题*分,共*分,共*题
                                     volume_score = N_s[1]
                                     item_count = N_s[2]
                                     item_score = N_s[0]
@@ -281,11 +313,11 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif num_back0 == '分' and num_back2 == '分':
-                                if N_s[0] > N_s[2]:    # 第卷,共*分,共*题,每题*分
+                                if N_s[0] > N_s[2]:  # 第卷,共*分,共*题,每题*分
                                     volume_score = N_s[0]
                                     item_count = N_s[1]
                                     item_score = N_s[2]
-                                else:                  # 第卷,每题*分,共*题,共*分
+                                else:  # 第卷,每题*分,共*题,共*分
                                     volume_score = N_s[2]
                                     item_count = N_s[1]
                                     item_score = N_s[0]
@@ -355,7 +387,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 return all_structure
                     else:
                         if keyword_item3.search(C_s):
-                            if (num_back0 == '卷' or num_back0 == '部') and (num_back1 == '题' or num_back1 == '小') and num_back2 == '分':  # 第*卷,共*题,共*分
+                            if (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back1 == '题' or num_back1 == '小') and num_back2 == '分':  # 第*卷,共*题,共*分
                                 volume_N = N_s[0]
                                 volume_score = N_s[2]
                                 item_count = N_s[1]
@@ -364,7 +397,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back2 == '题' or num_back2 == '小') and num_back1 == '分':  # 第*卷,共*分,共*题
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back2 == '题' or num_back2 == '小') and num_back1 == '分':  # 第*卷,共*分,共*题
                                 volume_N = N_s[0]
                                 volume_score = N_s[1]
                                 item_count = N_s[2]
@@ -373,7 +407,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back0 == '.' and num_infer1 == '.' and (num_back2 == '题' or num_back2 == '小') and num_back1 == '分':  # 第卷,共*.*分,共*题
+                            elif num_back0 == '.' and num_infer1 == '.' and (
+                                    num_back2 == '题' or num_back2 == '小') and num_back1 == '分':  # 第卷,共*.*分,共*题
                                 volume_N = -1
                                 volume_score = N_s[0]
                                 item_count = N_s[2]
@@ -382,7 +417,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back1 == '.' and num_infer2 == '.' and (num_back0 == '题' or num_back0 == '小') and num_back2 == '分':  # 第卷,共*题,共*.*分
+                            elif num_back1 == '.' and num_infer2 == '.' and (
+                                    num_back0 == '题' or num_back0 == '小') and num_back2 == '分':  # 第卷,共*题,共*.*分
                                 volume_N = -1
                                 volume_score = N_s[1]
                                 item_count = N_s[0]
@@ -507,12 +543,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                     if keyword_item2.search(C_s):
                         if keyword_item3.search(C_s):
                             if (num_back0 == '卷' or num_back0 == '部') and num_back1 == '分' and num_back3 == '分':
-                                if N_s[3] > N_s[1]:    # 第*卷,每题*分,共*题,共*分
+                                if N_s[3] > N_s[1]:  # 第*卷,每题*分,共*题,共*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[3]
                                     item_count = N_s[2]
                                     item_score = N_s[1]
-                                else:                 # 第*卷,共*分,共*题,每题*分
+                                else:  # 第*卷,共*分,共*题,每题*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[1]
                                     item_count = N_s[2]
@@ -522,12 +558,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif (num_back0 == '卷' or num_back0 == '部') and num_back2 == '分' and num_back3 == '分':
-                                if N_s[3] > N_s[2]:     # 第*卷,共*题,每题*分,共*分
+                                if N_s[3] > N_s[2]:  # 第*卷,共*题,每题*分,共*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[3]
                                     item_count = N_s[1]
                                     item_score = N_s[2]
-                                else:                   # 第*卷,共*题,共*分 , 每题*分
+                                else:  # 第*卷,共*题,共*分 , 每题*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[2]
                                     item_count = N_s[1]
@@ -537,12 +573,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif (num_back0 == '卷' or num_back0 == '部') and num_back2 == '分' and num_back1 == '分':
-                                if N_s[1] > N_s[2]:       # 第*卷,共*分,每题*分,共*题
+                                if N_s[1] > N_s[2]:  # 第*卷,共*分,每题*分,共*题
                                     volume_N = N_s[0]
                                     volume_score = N_s[1]
                                     item_count = N_s[3]
                                     item_score = N_s[2]
-                                else:                     # 第*卷,每题*分,共*分,共*题
+                                else:  # 第*卷,每题*分,共*分,共*题
                                     volume_N = N_s[0]
                                     volume_score = N_s[2]
                                     item_count = N_s[3]
@@ -551,7 +587,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '.' and num_infer1 == '.') and num_back1 == '分' and num_back2 == '分':  # 第卷,每题*.*分,共*分,共*题/第卷,共*.*分,每题*分,共*题
+                            elif (
+                                    num_back0 == '.' and num_infer1 == '.') and num_back1 == '分' and num_back2 == '分':  # 第卷,每题*.*分,共*分,共*题/第卷,共*.*分,每题*分,共*题
                                 volume_N = -1
                                 if int(N_s[0]) > int(N_s[2]):
                                     volume_score = N_s[0]
@@ -565,7 +602,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back1 == '.' and num_infer2 == '.') and num_back0 == '分' and num_back2 == '分':  # 第卷,每题*分,共*.*分,共*题/第卷,共*分,每题*.*分,共*题
+                            elif (
+                                    num_back1 == '.' and num_infer2 == '.') and num_back0 == '分' and num_back2 == '分':  # 第卷,每题*分,共*.*分,共*题/第卷,共*分,每题*.*分,共*题
                                 volume_N = -1
                                 if int(N_s[0]) > int(N_s[1]):
                                     volume_score = N_s[0]
@@ -579,7 +617,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back3 == '分':  # 第卷,共*题,共*.*分,每题*分/第卷,共*题,每题*.*分,共*分
+                            elif (
+                                    num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back3 == '分':  # 第卷,共*题,共*.*分,每题*分/第卷,共*题,每题*.*分,共*分
                                 volume_N = -1
                                 if N_s[1] > N_s[3]:
                                     volume_score = N_s[1]
@@ -593,7 +632,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back2 == '.' and num_infer3 == '.') and num_back1 == '分' and num_back3 == '分':  # 第卷,共*题,共*分,每题*.*分/第卷,共*题,每题*分,共*.*分
+                            elif (
+                                    num_back2 == '.' and num_infer3 == '.') and num_back1 == '分' and num_back3 == '分':  # 第卷,共*题,共*分,每题*.*分/第卷,共*题,每题*分,共*.*分
                                 volume_N = -1
                                 if int(N_s[1]) > int(N_s[2]):
                                     volume_score = N_s[1]
@@ -607,7 +647,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '.' and num_infer1 == '.') and num_back1 == '分' and num_back3 == '分':  # 第卷,共*.*分,共*题,每题*分/第卷,每题*.*分,共*题,共*分
+                            elif (
+                                    num_back0 == '.' and num_infer1 == '.') and num_back1 == '分' and num_back3 == '分':  # 第卷,共*.*分,共*题,每题*分/第卷,每题*.*分,共*题,共*分
                                 volume_N = -1
                                 if int(N_s[0]) > int(N_s[3]):
                                     volume_score = N_s[0]
@@ -621,7 +662,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back2 == '.' and num_infer3 == '.') and num_back0 == '分' and num_back3 == '分':  # 第卷,共*分,共*题,每题*.*分/第卷,每题*分,共*题,共*.*分
+                            elif (
+                                    num_back2 == '.' and num_infer3 == '.') and num_back0 == '分' and num_back3 == '分':  # 第卷,共*分,共*题,每题*.*分/第卷,每题*分,共*题,共*.*分
                                 volume_N = -1
                                 if int(N_s[0]) > int(N_s[2]):
                                     volume_score = N_s[0]
@@ -636,7 +678,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                         else:
-                            if (num_back0 == '卷' or num_back0 == '部') and num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back3 == '分':  # 第*卷,每题*.*分,共*分/第*卷,共*.*分,每题*分
+                            if (
+                                    num_back0 == '卷' or num_back0 == '部') and num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back3 == '分':  # 第*卷,每题*.*分,共*分/第*卷,共*.*分,每题*分
                                 volume_N = int(N_s[0])
                                 if N_s[1] > N_s[3]:
                                     volume_score = N_s[1]
@@ -650,7 +693,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = volume_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and num_back2 == '.' and num_infer3 == '.' and num_back1 == '分' and num_back3 == '分':  # 第*卷,每题*分,共*.*分/第*卷,共*分,每题*.*分
+                            elif (
+                                    num_back0 == '卷' or num_back0 == '部') and num_back2 == '.' and num_infer3 == '.' and num_back1 == '分' and num_back3 == '分':  # 第*卷,每题*分,共*.*分/第*卷,共*分,每题*.*分
                                 volume_N = int(N_s[0])
                                 if int(N_s[1]) > int(N_s[2]):
                                     volume_score = N_s[1]
@@ -679,12 +723,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif (num_back0 == '卷' or num_back0 == '部') and num_back1 == '分' and num_back2 == '分':
-                                if N_s[3] > N_s[1]:              # 第*卷,每题*.*分,共*分
+                                if N_s[3] > N_s[1]:  # 第*卷,每题*.*分,共*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[3]
                                     item_count = -1
                                     item_score = float(N_s[1] + '.' + N_s[2])
-                                else:                            # 第*卷,共*.*分,每题*分
+                                else:  # 第*卷,共*.*分,每题*分
                                     volume_N = N_s[0]
                                     volume_score = N_s[1]
                                     item_count = -1
@@ -813,7 +857,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                 if keyword_item1.search(C_s):
                     if keyword_item2.search(C_s):
                         if keyword_item3.search(C_s):
-                            if (num_back0 == '卷' or num_back0 == '部') and (num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back3 == '分':  # 第*卷,每题*.*分,共*分,共*题/第卷,共*.*分,每题*分,共*题
+                            if (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back3 == '分':  # 第*卷,每题*.*分,共*分,共*题/第卷,共*.*分,每题*分,共*题
                                 volume_N = N_s[0]
                                 if N_s[1] > N_s[3]:
                                     volume_score = N_s[1]
@@ -831,7 +876,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     type_score_dict_ocr['volume_total_score'] = volume_score
                                     type_score_dict_ocr['volume_count'] = item_count
                                     type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back2 == '.' and num_infer3 == '.') and num_back1 == '分' and num_back3 == '分':  # 第*卷,每题*分,共*.*分,共*题/第卷,共*分,每题*.*分,共*题
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back2 == '.' and num_infer3 == '.') and num_back1 == '分' and num_back3 == '分':  # 第*卷,每题*分,共*.*分,共*题/第卷,共*分,每题*.*分,共*题
                                 volume_N = N_s[0]
                                 if N_s[1] > N_s[2]:
                                     volume_score = N_s[1]
@@ -849,7 +895,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     type_score_dict_ocr['volume_total_score'] = volume_score
                                     type_score_dict_ocr['volume_count'] = item_count
                                     type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back2 == '.' and num_infer3 == '.') and num_back3 == '分' and num_back4 == '分':  # 第卷,共*题,共*.*分,每题*分/第卷,共*题,每题*.*分,共*分
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back2 == '.' and num_infer3 == '.') and num_back3 == '分' and num_back4 == '分':  # 第卷,共*题,共*.*分,每题*分/第卷,共*题,每题*.*分,共*分
                                 volume_N = N_s[0]
                                 if N_s[2] > N_s[4]:
                                     volume_score = N_s[2]
@@ -867,7 +914,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     type_score_dict_ocr['volume_total_score'] = volume_score
                                     type_score_dict_ocr['volume_count'] = item_count
                                     type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back3 == '.' and num_infer4 == '.') and num_back2 == '分' and num_back4 == '分':  # 第*卷,共*题,共*分,每题*.*分/第卷,共*题,每题*分,共*.*分
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back3 == '.' and num_infer4 == '.') and num_back2 == '分' and num_back4 == '分':  # 第*卷,共*题,共*分,每题*.*分/第卷,共*题,每题*分,共*.*分
                                 volume_N = N_s[0]
                                 if N_s[2] > N_s[3]:
                                     volume_score = N_s[2]
@@ -885,7 +933,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     type_score_dict_ocr['volume_total_score'] = volume_score
                                     type_score_dict_ocr['volume_count'] = item_count
                                     type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back4 == '分':  # 第*卷,共*.*分,共*题,每题*分/第*卷,每题*.*分,共*题,共*分
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back1 == '.' and num_infer2 == '.') and num_back2 == '分' and num_back4 == '分':  # 第*卷,共*.*分,共*题,每题*分/第*卷,每题*.*分,共*题,共*分
                                 volume_N = N_s[0]
                                 if N_s[1] > N_s[4]:
                                     volume_score = N_s[1]
@@ -903,7 +952,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     type_score_dict_ocr['volume_total_score'] = volume_score
                                     type_score_dict_ocr['volume_count'] = item_count
                                     type_score_dict_ocr['volume_score'] = item_score
-                            elif (num_back0 == '卷' or num_back0 == '部') and (num_back3 == '.' and num_infer4 == '.') and num_back1 == '分' and num_back4 == '分':  # 第*卷,共*分,共*题,每题*.*分/第卷,每题*分,共*题,共*.*分
+                            elif (num_back0 == '卷' or num_back0 == '部') and (
+                                    num_back3 == '.' and num_infer4 == '.') and num_back1 == '分' and num_back4 == '分':  # 第*卷,共*分,共*题,每题*.*分/第卷,每题*分,共*题,共*.*分
                                 volume_N = N_s[0]
                                 if N_s[1] > N_s[3]:
                                     volume_score = N_s[0]
@@ -995,11 +1045,11 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                     if isinstance(N_s[1], str):
                         N_s[1] = int(N_s[1])
                     if keyword_item2.search(C_s):
-                        if N_s[0] > N_s[1]:    # 选择题/主观题/客观题,共*分,每题*分
+                        if N_s[0] > N_s[1]:  # 选择题/主观题/客观题,共*分,每题*分
                             item_total_score = int(N_s[0])
                             item_count = int(N_s[0] / N_s[1])
                             item_score = N_s[1]
-                        else:                  # 选择题/主观题/客观题,每题*分,共*分
+                        else:  # 选择题/主观题/客观题,每题*分,共*分
                             item_total_score = int(N_s[1])
                             item_count = int(N_s[1] / N_s[0])
                             item_score = N_s[0]
@@ -1029,7 +1079,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             else:
                                 return all_structure
                         else:
-                            if num_back0 == '.' and num_infer1 == '.' and num_back1 == '分':   # *.*分
+                            if num_back0 == '.' and num_infer1 == '.' and num_back1 == '分':  # *.*分
                                 item_N = -1
                                 item_total_score = N_s[0]
                                 type_score_dict_ocr['volume_N'] = item_N
@@ -1081,7 +1131,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_total_score = N_s[2]
                                     item_count = N_s[1]
                                     item_score = N_s[0]
-                                else:                # 共*分,共*题,每题*分
+                                else:  # 共*分,共*题,每题*分
                                     item_total_score = N_s[0]
                                     item_count = N_s[1]
                                     item_score = N_s[2]
@@ -1096,7 +1146,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_total_score = N_s[1]
                                     item_count = N_s[2]
                                     item_score = N_s[0]
-                                else:                # 共*分,每题*分 ,共*题
+                                else:  # 共*分,每题*分 ,共*题
                                     item_total_score = N_s[0]
                                     item_count = N_s[2]
                                     item_score = N_s[1]
@@ -1107,11 +1157,11 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif num_back1 == '分' and num_back2 == '分':
-                                if N_s[2] > N_s[1]:          # 共*题,每题*分,共*分
+                                if N_s[2] > N_s[1]:  # 共*题,每题*分,共*分
                                     item_total_score = N_s[2]
                                     item_count = N_s[0]
                                     item_score = N_s[1]
-                                else:                        # 共*题,共*分,每题*分
+                                else:  # 共*题,共*分,每题*分
                                     item_total_score = N_s[1]
                                     item_count = N_s[0]
                                     item_score = N_s[2]
@@ -1125,12 +1175,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 return all_structure
                         else:
                             if num_back0 != '.' and num_back1 == '分' and num_back2 == '分':
-                                if N_s[1] > N_s[2]:   # *,共*分,每题*分
+                                if N_s[1] > N_s[2]:  # *,共*分,每题*分
                                     item_N = N_s[0]
                                     item_total_score = N_s[1]
                                     item_count = int(N_s[1] / N_s[2])
                                     item_score = N_s[2]
-                                else:                # *,每题*分 ,共*分
+                                else:  # *,每题*分 ,共*分
                                     item_N = N_s[0]
                                     item_total_score = N_s[2]
                                     item_count = int(N_s[2] / N_s[1])
@@ -1144,10 +1194,10 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 if int(N_s[0]) > int(N_s[2]):
                                     item_total_score = N_s[0]
                                     item_score = N_s[2]
-                                    item_count = int(item_total_score/item_score)
+                                    item_count = int(item_total_score / item_score)
                                 else:
                                     item_total_score = N_s[2]
-                                    item_score = float(N_s[0]+'.'+N_s[1])
+                                    item_score = float(N_s[0] + '.' + N_s[1])
                                     item_count = int(item_total_score / item_score)
                                 type_score_dict_ocr['volume_N'] = item_N
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
@@ -1157,8 +1207,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 item_N = -1
                                 if int(N_s[0]) > int(N_s[1]):
                                     item_total_score = N_s[0]
-                                    item_score = float(N_s[1]+'.'+N_s[2])
-                                    item_count = int(item_total_score/item_score)
+                                    item_score = float(N_s[1] + '.' + N_s[2])
+                                    item_count = int(item_total_score / item_score)
                                 else:
                                     item_total_score = N_s[1]
                                     item_score = N_s[0]
@@ -1171,34 +1221,34 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 return all_structure
                     else:
                         if keyword_item3.search(C_s):
-                            if num_back2 == '分' and num_infer2 =='.' and num_back1 =='.':  # *小题,共*.*分,
+                            if num_back2 == '分' and num_infer2 == '.' and num_back1 == '.':  # *小题,共*.*分,
                                 item_N = -1
                                 item_total_score = N_s[1]
                                 item_count = N_s[0]
-                                item_score = N_s[1]/N_s[0]
+                                item_score = N_s[1] / N_s[0]
                                 type_score_dict_ocr['volume_N'] = item_N
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back1 == '分' and num_infer1 =='.'and num_back0 =='.':  # 共*.*分,*小题
+                            elif num_back1 == '分' and num_infer1 == '.' and num_back0 == '.':  # 共*.*分,*小题
                                 item_N = -1
                                 item_total_score = N_s[0]
                                 item_count = N_s[2]
-                                item_score = N_s[0]/N_s[2]
+                                item_score = N_s[0] / N_s[2]
                                 type_score_dict_ocr['volume_N'] = item_N
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back2 == '分' and num_infer2 !='.':  # *,*小题,共*分,
+                            elif num_back2 == '分' and num_infer2 != '.':  # *,*小题,共*分,
                                 item_N = N_s[0]
                                 item_total_score = N_s[2]
                                 item_count = N_s[1]
-                                item_score = N_s[2]/N_s[1]
+                                item_score = N_s[2] / N_s[1]
                                 type_score_dict_ocr['volume_N'] = item_N
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back1 == '分' and num_infer1 !='.':  # *,共*分,共*小题
+                            elif num_back1 == '分' and num_infer1 != '.':  # *,共*分,共*小题
                                 item_N = N_s[0]
                                 item_total_score = N_s[1]
                                 item_count = N_s[2]
@@ -1210,7 +1260,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             else:
                                 return all_structure
                         else:
-                            if num_back2 == '分' and num_infer2 =='.' and num_back1 =='.':  # *,共*.*分,
+                            if num_back2 == '分' and num_infer2 == '.' and num_back1 == '.':  # *,共*.*分,
                                 item_N = N_s[0]
                                 item_total_score = N_s[1]
                                 item_count = -1
@@ -1229,7 +1279,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             else:
-                                return  all_structure
+                                return all_structure
                 elif len(N_s) == 4:
                     num_index1 = s.index(N_s[0])
                     num_infer0 = s[num_index1 - len(N_s[0])]
@@ -1278,12 +1328,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                     if keyword_item2.search(C_s):
                         if keyword_item3.search(C_s):
                             if num_back1 == '分' and num_back3 == '分':
-                                if N_s[3] > N_s[1]:   # *,每题*分,共*题,共*分
+                                if N_s[3] > N_s[1]:  # *,每题*分,共*题,共*分
                                     item_N = N_s[0]
                                     item_total_score = N_s[3]
                                     item_count = N_s[2]
                                     item_score = N_s[1]
-                                else:                # *,共*分,共*题,每题*分
+                                else:  # *,共*分,共*题,每题*分
                                     item_N = N_s[0]
                                     item_total_score = N_s[1]
                                     item_count = N_s[2]
@@ -1294,12 +1344,12 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif num_back1 == '分' and num_back2 == '分':
-                                if N_s[2] > N_s[1]:   # *,每题*分,共*分,共*题
+                                if N_s[2] > N_s[1]:  # *,每题*分,共*分,共*题
                                     item_N = N_s[0]
                                     item_total_score = N_s[2]
                                     item_count = N_s[3]
                                     item_score = N_s[1]
-                                else:                # *,共*分,每题*分,共*题
+                                else:  # *,共*分,每题*分,共*题
                                     item_N = N_s[0]
                                     item_total_score = N_s[1]
                                     item_count = N_s[3]
@@ -1312,7 +1362,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
                             elif num_back2 == '分' and num_back3 == '分':
-                                if N_s[3] > N_s[2]: # *,共*题,每题*分,共*分
+                                if N_s[3] > N_s[2]:  # *,共*题,每题*分,共*分
                                     item_N = N_s[0]
                                     item_total_score = N_s[3]
                                     item_count = N_s[1]
@@ -1329,7 +1379,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     'volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back0 == '.' and num_infer1 == '.' and num_back1 == '分'and num_back3 == '分' :  # 共*.*分,共*题, 每题*分/每题*.*分,共*题,共*分
+                            elif num_back0 == '.' and num_infer1 == '.' and num_back1 == '分' and num_back3 == '分':  # 共*.*分,共*题, 每题*分/每题*.*分,共*题,共*分
                                 item_N = -1
                                 if N_s[0] > N_s[3]:
                                     item_total_score = N_s[0]
@@ -1340,10 +1390,10 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_score = float(N_s[0] + '.' + N_s[1])
                                     item_count = int(item_total_score / item_score)
                                 type_score_dict_ocr['volume_N'] = item_N
-                                type_score_dict_ocr[ 'item_total_score'] = item_total_score
+                                type_score_dict_ocr['item_total_score'] = item_total_score
                                 type_score_dict_ocr['item_count'] = item_count
                                 type_score_dict_ocr['item_score'] = item_score
-                            elif num_back2 == '.' and num_infer3 == '.' and num_back0 == '分'and num_back3 == '分':  # 共*分,共*题, 每题*.*分/每题*分,共*题,共*.*分
+                            elif num_back2 == '.' and num_infer3 == '.' and num_back0 == '分' and num_back3 == '分':  # 共*分,共*题, 每题*.*分/每题*分,共*题,共*.*分
                                 item_N = -1
                                 if N_s[0] > N_s[2]:
                                     item_total_score = N_s[0]
@@ -1354,10 +1404,10 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_score = N_s[0]
                                     item_count = int(item_total_score / item_score)
                                 type_score_dict_ocr['volume_N'] = item_N
-                                type_score_dict_ocr[ 'item_total_score'] = item_total_score
+                                type_score_dict_ocr['item_total_score'] = item_total_score
                                 type_score_dict_ocr['item_count'] = item_count
                                 type_score_dict_ocr['item_score'] = item_score
-                            elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分'and num_back3 == '分':  # 共*题,共*.*分,每题*分/共*题,每题*.*分,共*分
+                            elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back3 == '分':  # 共*题,共*.*分,每题*分/共*题,每题*.*分,共*分
                                 item_N = -1
                                 if N_s[1] > N_s[3]:
                                     item_total_score = N_s[1]
@@ -1371,7 +1421,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back2 == '.' and num_infer3 == '.' and num_back3 == '分'and num_back1 == '分' :  # 共*题,共*分,每题*.*分/共*题,每题*分,共*.*分
+                            elif num_back2 == '.' and num_infer3 == '.' and num_back3 == '分' and num_back1 == '分':  # 共*题,共*分,每题*.*分/共*题,每题*分,共*.*分
                                 item_N = -1
                                 if N_s[1] > N_s[2]:
                                     item_total_score = N_s[1]
@@ -1385,7 +1435,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back0 == '.' and num_infer1 == '.' and num_back1 == '分'and num_back2 == '分' :  # 每题*.*分,共*分,共*题/共*.*分,每题*分,共*题
+                            elif num_back0 == '.' and num_infer1 == '.' and num_back1 == '分' and num_back2 == '分':  # 每题*.*分,共*分,共*题/共*.*分,每题*分,共*题
                                 item_N = -1
                                 if N_s[0] > N_s[2]:
                                     item_total_score = N_s[0]
@@ -1399,7 +1449,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分'and num_back0 == '分' :  # 每题*分,共*.*分,共*题/共*分,每题*.*分,共*题
+                            elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back0 == '分':  # 每题*分,共*.*分,共*题/共*分,每题*.*分,共*题
                                 item_N = -1
                                 if N_s[0] > N_s[1]:
                                     item_total_score = N_s[0]
@@ -1416,7 +1466,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             else:
                                 return all_structure
                         else:
-                            if num_back1 == '.' and num_infer2 == '.' and num_back2 == '分'and num_back3 == '分' :  # *,共*.*分, 每题*分/每题*.*分,共*分
+                            if num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back3 == '分':  # *,共*.*分, 每题*分/每题*.*分,共*分
                                 item_N = N_s[0]
                                 if N_s[1] > N_s[3]:
                                     item_total_score = N_s[1]
@@ -1427,10 +1477,10 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_score = float(N_s[1] + '.' + N_s[2])
                                     item_count = int(item_total_score / item_score)
                                 type_score_dict_ocr['volume_N'] = item_N
-                                type_score_dict_ocr[ 'item_total_score'] = item_total_score
+                                type_score_dict_ocr['item_total_score'] = item_total_score
                                 type_score_dict_ocr['item_count'] = item_count
                                 type_score_dict_ocr['item_score'] = item_score
-                            elif num_back2== '.' and num_infer3== '.' and num_back1 == '分'and num_back3 == '分' :  # *,共*分, 每题*.*分/*,每题*分,共*.*分
+                            elif num_back2 == '.' and num_infer3 == '.' and num_back1 == '分' and num_back3 == '分':  # *,共*分, 每题*.*分/*,每题*分,共*.*分
                                 item_N = int(N_s[0])
                                 if N_s[1] > N_s[2]:
                                     item_total_score = N_s[1]
@@ -1441,7 +1491,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                     item_score = N_s[1]
                                     item_count = int(item_total_score / item_score)
                                 type_score_dict_ocr['volume_N'] = item_N
-                                type_score_dict_ocr[ 'item_total_score'] = item_total_score
+                                type_score_dict_ocr['item_total_score'] = item_total_score
                                 type_score_dict_ocr['item_count'] = item_count
                                 type_score_dict_ocr['item_score'] = item_score
                             else:
@@ -1457,7 +1507,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back2 == '分':   # *,共*.*分,*小题
+                            elif num_back2 == '分':  # *,共*.*分,*小题
                                 item_total_score = N_s[1]
                                 item_N = N_s[0]
                                 item_count = N_s[3]
@@ -1536,7 +1586,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                         N_s[4] = int(N_s[4])
                     if keyword_item2.search(C_s):
                         if keyword_item3.search(C_s):
-                            if num_back1== '.' and num_infer2== '.' and num_back2 == '分'and num_back3 == '分' :  # *,每题*.*分,共*分,*小题/*,共*.*分,每题*分,共*小题
+                            if num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back3 == '分':  # *,每题*.*分,共*分,*小题/*,共*.*分,每题*分,共*小题
                                 item_N = N_s[0]
                                 if N_s[1] > N_s[3]:
                                     item_total_score = N_s[1]
@@ -1550,7 +1600,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back2== '.' and num_infer3== '.' and num_back1 == '分'and num_back3 == '分' :  # *,每题*分,共*.*分,*小题/*,共*分,每题*.*分,共*小题
+                            elif num_back2 == '.' and num_infer3 == '.' and num_back1 == '分' and num_back3 == '分':  # *,每题*分,共*.*分,*小题/*,共*分,每题*.*分,共*小题
                                 item_N = N_s[0]
                                 if N_s[1] > N_s[2]:
                                     item_total_score = N_s[1]
@@ -1564,7 +1614,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back2== '.' and num_infer3== '.' and num_back3 == '分'and num_back4 == '分' :  # *,*小题,每题*.*分,共*分/*,*小题,共*.*分,每题*分
+                            elif num_back2 == '.' and num_infer3 == '.' and num_back3 == '分' and num_back4 == '分':  # *,*小题,每题*.*分,共*分/*,*小题,共*.*分,每题*分
                                 item_N = N_s[0]
                                 if N_s[2] > N_s[4]:
                                     item_total_score = N_s[2]
@@ -1578,7 +1628,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back3== '.' and num_infer4== '.' and num_back2 == '分'and num_back4 == '分' :  # *,*小题,每题*分,共*.*分/*,*小题,共*分,每题*.*分
+                            elif num_back3 == '.' and num_infer4 == '.' and num_back2 == '分' and num_back4 == '分':  # *,*小题,每题*分,共*.*分/*,*小题,共*分,每题*.*分
                                 item_N = N_s[0]
                                 if N_s[2] > N_s[3]:
                                     item_total_score = N_s[2]
@@ -1592,7 +1642,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back1== '.' and num_infer2== '.' and num_back2 == '分'and num_back4 == '分' :  # *,每题*.*分,*小题,共*分/*,共*.*分,*小题,每题*分
+                            elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and num_back4 == '分':  # *,每题*.*分,*小题,共*分/*,共*.*分,*小题,每题*分
                                 item_N = N_s[0]
                                 if N_s[1] > N_s[4]:
                                     item_total_score = N_s[1]
@@ -1606,7 +1656,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_total_score'] = item_total_score
                                 type_score_dict_ocr['volume_count'] = item_count
                                 type_score_dict_ocr['volume_score'] = item_score
-                            elif num_back3== '.' and num_infer4== '.' and num_back1 == '分'and num_back4 == '分' :  # *,每题*分,*小题,共*.*分/*,共*分,*小题,每题*.*分
+                            elif num_back3 == '.' and num_infer4 == '.' and num_back1 == '分' and num_back4 == '分':  # *,每题*分,*小题,共*.*分/*,共*分,*小题,每题*.*分
                                 item_N = N_s[0]
                                 if N_s[1] > N_s[3]:
                                     item_total_score = N_s[1]
@@ -1685,7 +1735,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                         else:
                             if num_back1 == '分' and num_back0 == '.' and num_infer1 == '.':  # *.*分
                                 item_N = -1
-                                item_score = float(N_s[0]+'.'+N_s[1])
+                                item_score = float(N_s[0] + '.' + N_s[1])
                                 type_score_dict_ocr['volume_N'] = item_N
                                 type_score_dict_ocr['volume_total_score'] = -1
                                 type_score_dict_ocr['volume_count'] = -1
@@ -1698,7 +1748,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 type_score_dict_ocr['volume_count'] = -1
                                 type_score_dict_ocr['volume_score'] = item_score
                             else:
-                                return  all_structure
+                                return all_structure
                     elif len(N_s) == 3:
                         num_index1 = s.index(N_s[0])
                         num_infer0 = s[num_index1 - len(N_s[0])]
@@ -1728,7 +1778,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             N_s[1] = int(N_s[1])
                         if isinstance(N_s[2], str):
                             N_s[2] = int(N_s[2])
-                        if num_back2 == '分' and (num_back1 == '题' or num_back1 == '小' or num_back1 == '空') and num_back0 != '分':  # *,共*题,每题*分
+                        if num_back2 == '分' and (
+                                num_back1 == '题' or num_back1 == '小' or num_back1 == '空') and num_back0 != '分':  # *,共*题,每题*分
                             item_N = int(N_s[0])
                             item_total_score = int(N_s[1]) * int(N_s[2])
                             item_count = int(N_s[1])
@@ -1737,7 +1788,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             type_score_dict_ocr['volume_total_score'] = item_total_score
                             type_score_dict_ocr['volume_count'] = item_count
                             type_score_dict_ocr['volume_score'] = item_score
-                        elif num_back1 == '分' and (num_back2 == '题' or num_back2 == '小' or num_back2 == '空') and num_back0 != '分':  # *,每题*分,共*题
+                        elif num_back1 == '分' and (
+                                num_back2 == '题' or num_back2 == '小' or num_back2 == '空') and num_back0 != '分':  # *,每题*分,共*题
                             item_N = int(N_s[0])
                             item_total_score = int(N_s[1]) * int(N_s[2])
                             item_count = int(N_s[2])
@@ -1749,13 +1801,13 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                         elif num_infer2 == '.' and num_back2 == '分' and num_back1 == '.':  # 共*题,每题*.*分
                             item_N = -1
                             item_count = int(N_s[0])
-                            item_score = float(N_s[1]+'.'+N_s[2])
+                            item_score = float(N_s[1] + '.' + N_s[2])
                             item_total_score = int(item_count * item_score)
                             type_score_dict_ocr['volume_N'] = item_N
                             type_score_dict_ocr['volume_total_score'] = item_total_score
                             type_score_dict_ocr['volume_count'] = item_count
                             type_score_dict_ocr['volume_score'] = item_score
-                        elif num_infer1 == '.' and num_back1 == '分' and num_back0 == '.' :  # 每题*.*分,共*题
+                        elif num_infer1 == '.' and num_back1 == '分' and num_back0 == '.':  # 每题*.*分,共*题
                             item_N = -1
                             item_count = int(N_s[2])
                             item_score = float(N_s[0] + '.' + N_s[1])
@@ -1764,7 +1816,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             type_score_dict_ocr['volume_total_score'] = item_total_score
                             type_score_dict_ocr['volume_count'] = item_count
                             type_score_dict_ocr['volume_score'] = item_score
-                        elif num_back2 == '分': # * * ,每题*分
+                        elif num_back2 == '分':  # * * ,每题*分
                             item_N = -1
                             item_count = -1
                             item_score = -1
@@ -1817,7 +1869,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             N_s[2] = int(N_s[2])
                         if isinstance(N_s[3], str):
                             N_s[3] = int(N_s[3])
-                        if num_back2 == '.' and num_infer3 == '.' and num_back3 == '分' and (num_back1 == '题' or num_back1 == '小' or num_back1 == '空') and num_back0 != '分':  # *,共*题,每题*.*分
+                        if num_back2 == '.' and num_infer3 == '.' and num_back3 == '分' and (
+                                num_back1 == '题' or num_back1 == '小' or num_back1 == '空') and num_back0 != '分':  # *,共*题,每题*.*分
                             item_N = int(N_s[0])
                             item_count = int(N_s[1])
                             item_score = float(N_s[2] + '.' + N_s[3])
@@ -1826,7 +1879,8 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                             type_score_dict_ocr['volume_total_score'] = item_total_score
                             type_score_dict_ocr['volume_count'] = item_count
                             type_score_dict_ocr['volume_score'] = item_score
-                        elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and (num_back3 == '题' or num_back3 == '小' or num_back3 == '空') and num_back0 != '分':  # *,每题*.*分,共*题
+                        elif num_back1 == '.' and num_infer2 == '.' and num_back2 == '分' and (
+                                num_back3 == '题' or num_back3 == '小' or num_back3 == '空') and num_back0 != '分':  # *,每题*.*分,共*题
                             item_N = int(N_s[0])
                             item_count = int(N_s[3])
                             item_score = float(N_s[1] + '.' + N_s[2])
@@ -1861,7 +1915,7 @@ def key_words(type_score_dict_ocr):  # 根据OCR结果结合关键字解析
                                 if isinstance(N_s[1], str):
                                     N_s[1] = int(N_s[1])
                                 if int(N_s[0]) > 1000:
-                                    item_N =0
+                                    item_N = 0
                                     item_N1 = int(N_s[0][-4] + N_s[0][-3])
                                     item_N2 = int(N_s[0][-2] + N_s[0][-1])
                                     if item_N2 - item_N1 == 1:

+ 10 - 1
segment/sheet_resolve/analysis/sheet/ocr_sheet.py

@@ -103,6 +103,7 @@ def tell_columns(image, sheet_dict):
 
 
 def ocr2sheet(image, sheet_dict, raw_ocr, xml_path=None):
+    image_y, image_x = image.shape[0], image.shape[1]
     col_split_list = tell_columns(image, sheet_dict)
     digital_p = r'\d'
     eng_char_p = '[\u0041-\u005a|\u0061-\u007a]'  # english
@@ -138,8 +139,11 @@ def ocr2sheet(image, sheet_dict, raw_ocr, xml_path=None):
     if raw_ocr:
         col_list.append(raw_ocr)
 
+    col_split_list.insert(0, 1)
+    col_split_list.append(image_x)
+
     block_list = []
-    for ocr_res in col_list:
+    for ii, ocr_res in enumerate(col_list):
         ocr_res = sorted(ocr_res, key=lambda x: x['location']['top'])
         raw_chn_index = []
         for i, words_line in enumerate(ocr_res):
@@ -164,6 +168,11 @@ def ocr2sheet(image, sheet_dict, raw_ocr, xml_path=None):
                           if ele['location']['width'] >= ele['location']['height']]) - 10
         right_limit = max([ele['location']['right'] for ele in ocr_res
                            if ele['location']['width'] >= ele['location']['height']]) + 10
+
+        # 文字识别结果可能连横跨栏,并导致文字分栏错误
+        left_limit = max(left_limit, col_split_list[ii])
+        right_limit = min(right_limit, col_split_list[ii+1])
+
         chn_index = raw_chn_index.copy()
         if ocr_res_len - 1 not in raw_chn_index:
             chn_index.append(len(ocr_res) - 1)

+ 1 - 1
segment/sheet_resolve/analysis/sheet/sheet_infer.py

@@ -303,7 +303,7 @@ def adjust_exam_number(regions):
 
     exam_number_w_index = 0
     if len(exam_number_w_regions) > 1:
-        distance = [abs(int(ele['bounding_box']['ymax']) - int(exam_number_region['bounding_box']['ymin ']))
+        distance = [abs(int(ele['bounding_box']['ymax']) - int(exam_number_region['bounding_box']['ymin']))
                     for ele in exam_number_w_regions]
         exam_number_w_index = distance.index(min(distance))
     exam_number_w_region = exam_number_w_regions[exam_number_w_index]

Plik diff jest za duży
+ 12 - 7
segment/sheet_resolve/analysis/sheet/sheet_points_total.py


+ 0 - 2
segment/sheet_resolve/tools/tf_sess.py

@@ -7,8 +7,6 @@ from segment.sheet_resolve.lib.model.config import cfg
 from segment.sheet_resolve.lib.nets.resnet_v1 import resnetv1
 from segment.sheet_resolve.tools.tf_settings import model_dict
 
-os.environ["CUDA_VISIBLE_DEVICES"] = '0'
-
 
 class TfSess:
 

+ 64 - 64
segment/sheet_resolve/tools/tf_settings.py

@@ -10,10 +10,10 @@ subject_list = ['math', 'math_zxhx', 'english', 'chinese',
 
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
-xml_template_path = os.path.join(BASE_DIR, 'model', 'labels', '000000-template.xml')
+xml_template_path = os.path.join(BASE_DIR, 'labels', '000000-template.xml')
 images_dir_path = os.path.join(BASE_DIR, 'images')
 model_dir_path = os.path.join(BASE_DIR, 'model')
-label_dir = os.path.join(BASE_DIR, 'model', 'labels')
+label_dir = os.path.join(BASE_DIR, 'model', 'subjects', 'labels')
 
 # ssd
 choice_m_ssd = os.path.join(model_dir_path, 'ssd_choice_m', 'frozen_inference_graph.pb')
@@ -29,29 +29,29 @@ cloze_model_path = os.path.join(model_dir_path, 'cloze', 'cloze' + '.ckpt')
 math_zxhx_model_path = os.path.join(model_dir_path, 'math_zxhx', 'sheet' + '.ckpt')
 math_zxhx_detail_model_path = os.path.join(model_dir_path, 'math_zxhx_detail', 'sheet' + '.ckpt')
 # 第三方
-math_model_path = os.path.join(model_dir_path, 'math', 'sheet' + '.ckpt')
-english_model_path = os.path.join(model_dir_path, 'english', 'sheet' + '.ckpt')
-chinese_model_path = os.path.join(model_dir_path, 'chinese', 'sheet' + '.ckpt')
-physics_model_path = os.path.join(model_dir_path, 'physics', 'sheet' + '.ckpt')
-chemistry_model_path = os.path.join(model_dir_path, 'chemistry', 'sheet' + '.ckpt')
-biology_model_path = os.path.join(model_dir_path, 'biology', 'sheet' + '.ckpt')
-politics_model_path = os.path.join(model_dir_path, 'politics', 'sheet' + '.ckpt')
-history_model_path = os.path.join(model_dir_path, 'history', 'sheet' + '.ckpt')
-geography_model_path = os.path.join(model_dir_path, 'geography', 'sheet' + '.ckpt')
-science_comprehensive_model_path = os.path.join(model_dir_path, 'science_comprehensive', 'sheet' + '.ckpt')
-arts_comprehensive_model_path = os.path.join(model_dir_path, 'arts_comprehensive', 'sheet' + '.ckpt')
+math_model_path = os.path.join(model_dir_path, 'subjects', 'math', 'sheet' + '.ckpt')
+english_model_path = os.path.join(model_dir_path, 'subjects', 'english', 'sheet' + '.ckpt')
+chinese_model_path = os.path.join(model_dir_path, 'subjects', 'chinese', 'sheet' + '.ckpt')
+physics_model_path = os.path.join(model_dir_path, 'subjects', 'physics', 'sheet' + '.ckpt')
+chemistry_model_path = os.path.join(model_dir_path, 'subjects', 'chemistry', 'sheet' + '.ckpt')
+biology_model_path = os.path.join(model_dir_path, 'subjects', 'biology', 'sheet' + '.ckpt')
+politics_model_path = os.path.join(model_dir_path, 'subjects', 'politics', 'sheet' + '.ckpt')
+history_model_path = os.path.join(model_dir_path, 'subjects', 'history', 'sheet' + '.ckpt')
+geography_model_path = os.path.join(model_dir_path, 'subjects', 'geography', 'sheet' + '.ckpt')
+science_comprehensive_model_path = os.path.join(model_dir_path, 'subjects', 'science_comprehensive', 'sheet' + '.ckpt')
+arts_comprehensive_model_path = os.path.join(model_dir_path, 'subjects', 'arts_comprehensive', 'sheet' + '.ckpt')
 
-math_blank_model_path = os.path.join(model_dir_path, 'math_blank', 'sheet' + '.ckpt')
-english_blank_model_path = os.path.join(model_dir_path, 'english_blank', 'sheet' + '.ckpt')
-chinese_blank_model_path = os.path.join(model_dir_path, 'chinese_blank', 'sheet' + '.ckpt')
-physics_blank_model_path = os.path.join(model_dir_path, 'physics_blank', 'sheet' + '.ckpt')
-chemistry_blank_model_path = os.path.join(model_dir_path, 'chemistry_blank', 'sheet' + '.ckpt')
-biology_blank_model_path = os.path.join(model_dir_path, 'biology_blank', 'sheet' + '.ckpt')
-politics_blank_model_path = os.path.join(model_dir_path, 'politics_blank', 'sheet' + '.ckpt')
-history_blank_model_path = os.path.join(model_dir_path, 'history_blank', 'sheet' + '.ckpt')
-geography_blank_model_path = os.path.join(model_dir_path, 'geography_blank', 'sheet' + '.ckpt')
-science_comprehensive_blank_model_path = os.path.join(model_dir_path, 'science_comprehensive_blank', 'sheet' + '.ckpt')
-arts_comprehensive_blank_model_path = os.path.join(model_dir_path, 'arts_comprehensive_blank', 'sheet' + '.ckpt')
+math_blank_model_path = os.path.join(model_dir_path, 'subjects', 'math_blank', 'sheet' + '.ckpt')
+english_blank_model_path = os.path.join(model_dir_path, 'subjects', 'english_blank', 'sheet' + '.ckpt')
+chinese_blank_model_path = os.path.join(model_dir_path, 'subjects', 'chinese_blank', 'sheet' + '.ckpt')
+physics_blank_model_path = os.path.join(model_dir_path, 'subjects', 'physics_blank', 'sheet' + '.ckpt')
+chemistry_blank_model_path = os.path.join(model_dir_path, 'subjects', 'chemistry_blank', 'sheet' + '.ckpt')
+biology_blank_model_path = os.path.join(model_dir_path, 'subjects', 'biology_blank', 'sheet' + '.ckpt')
+politics_blank_model_path = os.path.join(model_dir_path, 'subjects', 'politics_blank', 'sheet' + '.ckpt')
+history_blank_model_path = os.path.join(model_dir_path, 'subjects', 'history_blank', 'sheet' + '.ckpt')
+geography_blank_model_path = os.path.join(model_dir_path, 'subjects', 'geography_blank', 'sheet' + '.ckpt')
+science_comprehensive_blank_model_path = os.path.join(model_dir_path, 'subjects', 'science_comprehensive_blank', 'sheet' + '.ckpt')
+arts_comprehensive_blank_model_path = os.path.join(model_dir_path, 'subjects', 'arts_comprehensive_blank', 'sheet' + '.ckpt')
 
 choice_m_classes = ('__background__', 'choice_m')
 choice_classes = ('__background__', 'choice', 'choice', 'choice', 'choice', 'choice', 'choice', 'choice', 'choice',
@@ -80,15 +80,15 @@ geography_classes = read_label(label_dir, "geography")
 science_comprehensive_classes = read_label(label_dir, "science_comprehensive")
 arts_comprehensive_classes = read_label(label_dir, "arts_comprehensive")
 
-math_blank_classes = read_label(label_dir, "math_blank")
-english_blank_classes = read_label(label_dir, "english_blank")
+# math_blank_classes = read_label(label_dir, "math_blank")
+# english_blank_classes = read_label(label_dir, "english_blank")
 chinese_blank_classes = read_label(label_dir, "chinese_blank")
-physics_blank_classes = read_label(label_dir, "physics_blank")
-chemistry_blank_classes = read_label(label_dir, "chemistry_blank")
-biology_blank_classes = read_label(label_dir, "biology_blank")
-politics_blank_classes = read_label(label_dir, "politics_blank")
-history_blank_classes = read_label(label_dir, "history_blank")
-geography_blank_classes = read_label(label_dir, "geography_blank")
+# physics_blank_classes = read_label(label_dir, "physics_blank")
+# chemistry_blank_classes = read_label(label_dir, "chemistry_blank")
+# biology_blank_classes = read_label(label_dir, "biology_blank")
+# politics_blank_classes = read_label(label_dir, "politics_blank")
+# history_blank_classes = read_label(label_dir, "history_blank")
+# geography_blank_classes = read_label(label_dir, "geography_blank")
 science_comprehensive_blank_classes = read_label(label_dir, "science_comprehensive_blank")
 arts_comprehensive_blank_classes = read_label(label_dir, "arts_comprehensive_blank")
 
@@ -228,42 +228,42 @@ model_dict = {
                            'classes': arts_comprehensive_classes,
                            'class_coordinate_bias': arts_comprehensive_bias_dict},
 
-    'math_blank': dict(path=math_blank_model_path, anchor_scales=(1, 2, 4, 8, 16),
-                       anchor_ratios=(0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                       classes=math_blank_classes, class_coordinate_bias=math_bias_dict),
-    'english_blank': {'path': english_blank_model_path,
-                      'anchor_scales': (1, 2, 4, 8, 16),
-                      'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                      'classes': english_blank_classes, 'class_coordinate_bias': english_bias_dict},
+    # 'math_blank': dict(path=math_blank_model_path, anchor_scales=(1, 2, 4, 8, 16),
+    #                    anchor_ratios=(0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                    classes=math_blank_classes, class_coordinate_bias=math_bias_dict),
+    # 'english_blank': {'path': english_blank_model_path,
+    #                   'anchor_scales': (1, 2, 4, 8, 16),
+    #                   'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                   'classes': english_blank_classes, 'class_coordinate_bias': english_bias_dict},
     'chinese_blank': {'path': chinese_blank_model_path,
                       'anchor_scales': (1, 2, 4, 8, 16),
                       'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
                       'classes': chinese_blank_classes, 'class_coordinate_bias': chinese_bias_dict},
-    'physics_blank': {'path': physics_blank_model_path,
-                      'anchor_scales': (1, 2, 4, 8, 16),
-                      'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                      'classes': physics_blank_classes, 'class_coordinate_bias': physics_bias_dict},
-    'chemistry_blank': {'path': chemistry_blank_model_path,
-                        'anchor_scales': (1, 2, 4, 8, 16),
-                        'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                        'classes': chemistry_blank_classes, 'class_coordinate_bias': chemistry_bias_dict},
-    'biology_blank': {'path': biology_blank_model_path,
-                      'anchor_scales': (1, 2, 4, 8, 16),
-                      'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                      'classes': biology_blank_classes, 'class_coordinate_bias': biology_bias_dict},
-    'politics_blank': {'path': politics_blank_model_path,
-                       'anchor_scales': (1, 2, 4, 8, 16),
-                       'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                       'classes': politics_blank_classes,
-                       'class_coordinate_bias': politics_bias_dict},
-    'history_blank': {'path': history_blank_model_path,
-                      'anchor_scales': (1, 2, 4, 8, 16),
-                      'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                      'classes': history_blank_classes, 'class_coordinate_bias': history_bias_dict},
-    'geography_blank': {'path': geography_blank_model_path,
-                        'anchor_scales': (1, 2, 4, 8, 16),
-                        'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
-                        'classes': geography_blank_classes, 'class_coordinate_bias': geography_bias_dict},
+    # 'physics_blank': {'path': physics_blank_model_path,
+    #                   'anchor_scales': (1, 2, 4, 8, 16),
+    #                   'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                   'classes': physics_blank_classes, 'class_coordinate_bias': physics_bias_dict},
+    # 'chemistry_blank': {'path': chemistry_blank_model_path,
+    #                     'anchor_scales': (1, 2, 4, 8, 16),
+    #                     'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                     'classes': chemistry_blank_classes, 'class_coordinate_bias': chemistry_bias_dict},
+    # 'biology_blank': {'path': biology_blank_model_path,
+    #                   'anchor_scales': (1, 2, 4, 8, 16),
+    #                   'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                   'classes': biology_blank_classes, 'class_coordinate_bias': biology_bias_dict},
+    # 'politics_blank': {'path': politics_blank_model_path,
+    #                    'anchor_scales': (1, 2, 4, 8, 16),
+    #                    'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                    'classes': politics_blank_classes,
+    #                    'class_coordinate_bias': politics_bias_dict},
+    # 'history_blank': {'path': history_blank_model_path,
+    #                   'anchor_scales': (1, 2, 4, 8, 16),
+    #                   'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                   'classes': history_blank_classes, 'class_coordinate_bias': history_bias_dict},
+    # 'geography_blank': {'path': geography_blank_model_path,
+    #                     'anchor_scales': (1, 2, 4, 8, 16),
+    #                     'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),
+    #                     'classes': geography_blank_classes, 'class_coordinate_bias': geography_bias_dict},
     'science_comprehensive_blank': {'path': science_comprehensive_blank_model_path,
                                     'anchor_scales': (1, 2, 4, 8, 16),
                                     'anchor_ratios': (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4),

+ 1 - 1
segment/sheet_views.py

@@ -52,7 +52,7 @@ tf_sess_dict = {
     # 'math_zxhx': TfSess('math_zxhx'),
     # 'math_zxhx_detail': TfSess('math_zxhx_detail'),
 
-    'math': TfSess('math'),
+    # 'math': TfSess('math'),
     # 'english': TfSess('english'),
     # 'chinese': TfSess('chinese'),
     # 'physics': TfSess('physics'),

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików