File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 11import time
22from pathlib import Path
33
4+ import cv2
45import numpy as np
56import onnxruntime
67from PIL import Image
@@ -39,8 +40,10 @@ def _preprocess(self, image):
3940 def __call__ (self , content : InputType ):
4041 ss = time .perf_counter ()
4142 img = self .load_img (content )
42- img = self ._preprocess (img )
43- output = self .table_cls .run (None , {"input" : img })
43+ gray_img = cv2 .cvtColor (img , cv2 .COLOR_BGR2GRAY )
44+ gray_img = np .stack ((gray_img ,) * 3 , axis = - 1 )
45+ gray_img = self ._preprocess (gray_img )
46+ output = self .table_cls .run (None , {"input" : gray_img })
4447 predict = np .exp (output [0 ] - np .max (output [0 ], axis = 1 , keepdims = True ))
4548 predict /= np .sum (predict , axis = 1 , keepdims = True )
4649 predict_cla = np .argmax (predict , axis = 1 )[0 ]
You can’t perform that action at this time.
0 commit comments