def generate_result(pred_txt_dir,
                    output_dir='output',
                    class_names=wordname_15,
                    nms_thresh=0.1):
    """
    pred_txt_dir: dir of pred txt
    output_dir: dir of output
    class_names: class names of data
    """
    pred_txt_list = glob.glob("{}/*.txt".format(pred_txt_dir))

    # step1: summary pred bbox
    pred_classes = {}
    for class_name in class_names:
        pred_classes[class_name] = []

    for current_txt in pred_txt_list:
        img_id = os.path.split(current_txt)[1]
        img_id = img_id.split('.txt')[0]
        with open(current_txt) as f:
            res = f.readlines()
            for item in res:
                item = item.split(' ')
                pred_class = item[0]
                item[0] = img_id
                pred_bbox = ' '.join(item)
                pred_classes[pred_class].append(pred_bbox)

    pred_classes_lst = []
    for class_name in pred_classes.keys():
        print('class_name: {}, count: {}'.format(class_name,
                                                 len(pred_classes[class_name])))
        pred_classes_lst.append((class_name, pred_classes[class_name]))

    # step2: merge
    pool = Pool(len(class_names))
    nms = py_cpu_nms_poly_fast
    mergesingle_fn = partial(merge_single, output_dir, nms, nms_thresh)
    pool.map(mergesingle_fn, pred_classes_lst)

    pred_txt_dir: dir of pred txt
    output_dir: dir of output
    class_names: class names of data
    
configs/rotate/tools/generate_result.py