@@ -49,7 +49,6 @@ def non_max_suppression_end2end(prediction, conf_thres=0.25, iou_thres=0.45, cla
49
49
50
50
def non_max_suppression_mnne (prediction , conf_thres = 0.25 , iou_thres = 0.45 , classes = None , agnostic = False , nc = None ):
51
51
output = []
52
- print (prediction .shape )
53
52
54
53
xc = prediction [:, 4 ] > conf_thres # candidates
55
54
output = prediction [xc ]
@@ -58,9 +57,6 @@ def non_max_suppression_mnne(prediction, conf_thres=0.25, iou_thres=0.45, classe
58
57
print (output .shape )
59
58
60
59
i = torchvision .ops .nms (boxes , scores , iou_thres ) # NMS
61
- print (output [i ].shape )
62
-
63
- print (output [i ])
64
60
65
61
return output [i ]
66
62
@@ -87,7 +83,6 @@ def non_max_suppression_mnnd(prediction, conf_thres=0.25, iou_thres=0.45, classe
87
83
boxes , scores = x [:, :4 ] + c , x [:, 4 ] # boxes (offset by class), scores
88
84
i = torchvision .ops .nms (boxes , scores , iou_thres ) # NMS
89
85
output [xi ] = x [i ].view (- 1 , 6 )
90
- print (output [0 ])
91
86
92
87
return output [0 ]
93
88
@@ -118,7 +113,15 @@ def process(weight_path, img_path):
118
113
out = sess .run (['outputs' ], {'images' : image .numpy ()})[0 ]
119
114
out = torch .from_numpy (out )
120
115
121
- output = non_max_suppression_end2end (out , 0.50 , 0.50 , nc = 1 )
116
+ # 如果使用的是end2end的导出方式,则使用以下后处理
117
+ # output = non_max_suppression_end2end(out, 0.50, 0.50, nc=80)
118
+
119
+ # 如果使用的是mnnd的导出方式,则使用以下后处理
120
+ output = non_max_suppression_mnnd (out , 0.50 , 0.50 , nc = 80 )
121
+
122
+ # 如果使用的是mnne的导出方式,则使用以下后处理
123
+ # output = non_max_suppression_mnne(out, 0.50, 0.50, nc=80)
124
+
122
125
nimg = image [0 ].permute (1 , 2 , 0 ) * 255
123
126
nimg = nimg .cpu ().numpy ().astype (np .uint8 )
124
127
nimg = cv2 .cvtColor (nimg , cv2 .COLOR_BGR2RGB )
0 commit comments