@@ -122,7 +122,9 @@ def postprocess(self, output, print_output=True, top_k=1):
122
122
output: list
123
123
"""
124
124
if not isinstance (self .input_file , list ):
125
- self .input_file = [self .input_file , ]
125
+ self .input_file = [
126
+ self .input_file ,
127
+ ]
126
128
output = output [0 ] # [B, num_cls]
127
129
N = output .shape [0 ]
128
130
output = F .softmax (paddle .to_tensor (output ), axis = - 1 ).numpy ()
@@ -298,7 +300,7 @@ def _gen_props(self, pred_bm, pred_start, pred_end, print_output=True):
298
300
299
301
# print top-5 predictions
300
302
if print_output :
301
- print ("BMN Inference results of {0} :" .format (self .feat_path ))
303
+ print ("Current video file: {0} :" .format (self .feat_path ))
302
304
for pred in proposal_list [:5 ]:
303
305
print (pred )
304
306
@@ -400,6 +402,27 @@ def preprocess(self, input_file):
400
402
res .append (np .expand_dims (item , axis = 0 ).copy ())
401
403
return res
402
404
405
+ def postprocess (self , output , print_output = True ):
406
+ """
407
+ output: list
408
+ """
409
+ if not isinstance (self .input_file , list ):
410
+ self .input_file = [
411
+ self .input_file ,
412
+ ]
413
+ output = output [0 ] # [B, num_cls]
414
+ # output = F.softmax(paddle.to_tensor(output), axis=-1).numpy() # done in it's head
415
+ N = output .shape [0 ]
416
+ for i in range (N ):
417
+ classes = np .argpartition (output [i ], - self .top_k )[- self .top_k :]
418
+ classes = classes [np .argsort (- output [i , classes ])]
419
+ scores = output [i , classes ]
420
+ if print_output :
421
+ print ("Current video file: {0}" .format (self .input_file [i ]))
422
+ for j in range (self .top_k ):
423
+ print ("\t top-{0} class: {1}" .format (j + 1 , classes [j ]))
424
+ print ("\t top-{0} score: {1}" .format (j + 1 , scores [j ]))
425
+
403
426
404
427
@INFERENCE .register ()
405
428
class STGCN_Inference_helper (Base_Inference_helper ):
0 commit comments