@@ -34,6 +34,8 @@ def __init__(self, cfg: Dict[str, Any]):
3434 self .session = get_engine (cfg .engine_type )(cfg )
3535
3636 def __call__ (self , img_list : Union [np .ndarray , List [np .ndarray ]]) -> TextClsOutput :
37+ start_time = time .perf_counter ()
38+
3739 if isinstance (img_list , np .ndarray ):
3840 img_list = [img_list ]
3941
@@ -59,17 +61,17 @@ def __call__(self, img_list: Union[np.ndarray, List[np.ndarray]]) -> TextClsOutp
5961 norm_img_batch .append (norm_img )
6062 norm_img_batch = np .concatenate (norm_img_batch ).astype (np .float32 )
6163
62- starttime = time .time ()
6364 prob_out = self .session (norm_img_batch )
6465 cls_result = self .postprocess_op (prob_out )
65- elapse += time .time () - starttime
6666
6767 for rno , (label , score ) in enumerate (cls_result ):
6868 cls_res [indices [beg_img_no + rno ]] = (label , score )
6969 if "180" in label and score > self .cls_thresh :
7070 img_list [indices [beg_img_no + rno ]] = cv2 .rotate (
7171 img_list [indices [beg_img_no + rno ]], 1
7272 )
73+
74+ elapse = time .perf_counter () - start_time
7375 return TextClsOutput (img_list = img_list , cls_res = cls_res , elapse = elapse )
7476
7577 def resize_norm_img (self , img : np .ndarray ) -> np .ndarray :
0 commit comments