Skip to content

Commit 60e5df5

Browse files
committed
fix: use gray img for table cls
1 parent 4db0b43 commit 60e5df5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

table_cls/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import time
22
from pathlib import Path
33

4+
import cv2
45
import numpy as np
56
import onnxruntime
67
from 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]

0 commit comments

Comments
 (0)