Эх сурвалжийг харах

change dict to OrderedDict in voc

FlyingQianMM 5 жил өмнө
parent
commit
9964b7ad9f

+ 2 - 1
paddlex/cv/datasets/voc.py

@@ -17,6 +17,7 @@ import copy
 import os.path as osp
 import random
 import numpy as np
+from collections import OrderedDict
 import xml.etree.ElementTree as ET
 import paddlex.utils.logging as logging
 from .dataset import Dataset
@@ -66,7 +67,7 @@ class VOCDetection(Dataset):
         annotations['categories'] = []
         annotations['annotations'] = []
 
-        cname2cid = {}
+        cname2cid = OrderedDict()
         label_id = 1
         with open(label_list, 'r', encoding=get_encoding(label_list)) as fr:
             for line in fr.readlines():

+ 2 - 1
paddlex/cv/models/utils/visualize.py

@@ -16,6 +16,8 @@ import os
 import cv2
 import colorsys
 import numpy as np
+import matplotlib
+matplotlib.use('Agg')
 import matplotlib as mpl
 import matplotlib.pyplot as plt
 import matplotlib.figure as mplfigure
@@ -333,7 +335,6 @@ def draw_pr_curve(eval_details_file=None,
         return mean_s
 
     def cal_pr(coco_gt, coco_dt, iou_thresh, save_dir, style='bbox'):
-        import matplotlib.pyplot as plt
         from pycocotools.cocoeval import COCOeval
         coco_dt = loadRes(coco_gt, coco_dt)
         np.linspace = fixed_linspace