MCPcopy Index your code
hub / github.com/Charmve/Surface-Defect-Detection / evaluate_method

Function evaluate_method

DeepPCB/evaluation/script.py:57–435  ·  view source on GitHub ↗

Method evaluate_method: evaluate method and returns the results Results. Dictionary with the following values: - method (required) Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 } - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Re

(gtFilePath, submFilePath, evaluationParams)

Source from the content-addressed store, hash-verified

55
56
57def evaluate_method(gtFilePath, submFilePath, evaluationParams):
58 """
59 Method evaluate_method: evaluate method and returns the results
60 Results. Dictionary with the following values:
61 - method (required) Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 }
62 - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Recall':0.9 } , 'sample2' : { 'Precision':0.8,'Recall':0.9 }
63 """
64 for module,alias in evaluation_imports().iteritems():
65 globals()[alias] = importlib.import_module(module)
66
67 def polygon_from_points(points,correctOffset=False):
68 """
69 Returns a Polygon object to use with the Polygon2 class from a list of 8 points: x1,y1,x2,y2,x3,y3,x4,y4
70 """
71
72 if correctOffset: #this will substract 1 from the coordinates that correspond to the xmax and ymax
73 points[2] -= 1
74 points[4] -= 1
75 points[5] -= 1
76 points[7] -= 1
77
78 resBoxes=np.empty([1,8],dtype='int32')
79 resBoxes[0,0]=int(points[0])
80 resBoxes[0,4]=int(points[1])
81 resBoxes[0,1]=int(points[2])
82 resBoxes[0,5]=int(points[3])
83 resBoxes[0,2]=int(points[4])
84 resBoxes[0,6]=int(points[5])
85 resBoxes[0,3]=int(points[6])
86 resBoxes[0,7]=int(points[7])
87 pointMat = resBoxes[0].reshape([2,4]).T
88 return plg.Polygon( pointMat)
89
90 def rectangle_to_polygon(rect):
91 resBoxes=np.empty([1,8],dtype='int32')
92 resBoxes[0,0]=int(rect.xmin)
93 resBoxes[0,4]=int(rect.ymax)
94 resBoxes[0,1]=int(rect.xmin)
95 resBoxes[0,5]=int(rect.ymin)
96 resBoxes[0,2]=int(rect.xmax)
97 resBoxes[0,6]=int(rect.ymin)
98 resBoxes[0,3]=int(rect.xmax)
99 resBoxes[0,7]=int(rect.ymax)
100
101 pointMat = resBoxes[0].reshape([2,4]).T
102
103 return plg.Polygon( pointMat)
104
105 def rectangle_to_points(rect):
106 points = [int(rect.xmin), int(rect.ymax), int(rect.xmax), int(rect.ymax), int(rect.xmax), int(rect.ymin), int(rect.xmin), int(rect.ymin)]
107 return points
108
109 def get_union(pD,pG):
110 areaA = pD.area();
111 areaB = pG.area();
112 return areaA + areaB - get_intersection(pD, pG);
113
114 def get_intersection_over_union(pD,pG):

Callers

nothing calls this directly

Calls 9

evaluation_importsFunction · 0.85
rectangle_to_polygonFunction · 0.85
polygon_from_pointsFunction · 0.85
include_in_dictionaryFunction · 0.85
get_intersectionFunction · 0.85
transcription_matchFunction · 0.85
compute_apFunction · 0.85

Tested by

no test coverage detected