transforms.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import os
  15. import sys
  16. import cv2
  17. import copy
  18. import math
  19. import pyclipper
  20. import numpy as np
  21. from PIL import Image
  22. from shapely.geometry import Polygon
  23. from ....utils import logging
  24. from ...base.predictor.io.writers import ImageWriter
  25. from ...base.predictor.io.readers import ImageReader
  26. from ...base.predictor import BaseTransform
  27. from .keys import TextDetKeys as K
  28. __all__ = [
  29. 'DetResizeForTest', 'NormalizeImage', 'DBPostProcess', 'SaveTextDetResults',
  30. 'PrintResult'
  31. ]
  32. class DetResizeForTest(BaseTransform):
  33. """ DetResizeForTest """
  34. def __init__(self, **kwargs):
  35. super(DetResizeForTest, self).__init__()
  36. self.resize_type = 0
  37. self.keep_ratio = False
  38. if 'image_shape' in kwargs:
  39. self.image_shape = kwargs['image_shape']
  40. self.resize_type = 1
  41. if 'keep_ratio' in kwargs:
  42. self.keep_ratio = kwargs['keep_ratio']
  43. elif 'limit_side_len' in kwargs:
  44. self.limit_side_len = kwargs['limit_side_len']
  45. self.limit_type = kwargs.get('limit_type', 'min')
  46. elif 'resize_long' in kwargs:
  47. self.resize_type = 2
  48. self.resize_long = kwargs.get('resize_long', 960)
  49. else:
  50. self.limit_side_len = 736
  51. self.limit_type = 'min'
  52. def apply(self, data):
  53. """ apply """
  54. img = data[K.IMAGE]
  55. src_h, src_w, _ = img.shape
  56. if sum([src_h, src_w]) < 64:
  57. img = self.image_padding(img)
  58. if self.resize_type == 0:
  59. # img, shape = self.resize_image_type0(img)
  60. img, [ratio_h, ratio_w] = self.resize_image_type0(img)
  61. elif self.resize_type == 2:
  62. img, [ratio_h, ratio_w] = self.resize_image_type2(img)
  63. else:
  64. # img, shape = self.resize_image_type1(img)
  65. img, [ratio_h, ratio_w] = self.resize_image_type1(img)
  66. data[K.IMAGE] = img
  67. data[K.SHAPE] = np.array([src_h, src_w, ratio_h, ratio_w])
  68. return data
  69. @classmethod
  70. def get_input_keys(cls):
  71. """ get input keys """
  72. return [K.IMAGE]
  73. @classmethod
  74. def get_output_keys(cls):
  75. """ get output keys """
  76. return [K.IMAGE, K.SHAPE]
  77. def image_padding(self, im, value=0):
  78. """ padding image """
  79. h, w, c = im.shape
  80. im_pad = np.zeros((max(32, h), max(32, w), c), np.uint8) + value
  81. im_pad[:h, :w, :] = im
  82. return im_pad
  83. def resize_image_type1(self, img):
  84. """ resize the image """
  85. resize_h, resize_w = self.image_shape
  86. ori_h, ori_w = img.shape[:2] # (h, w, c)
  87. if self.keep_ratio is True:
  88. resize_w = ori_w * resize_h / ori_h
  89. N = math.ceil(resize_w / 32)
  90. resize_w = N * 32
  91. ratio_h = float(resize_h) / ori_h
  92. ratio_w = float(resize_w) / ori_w
  93. img = cv2.resize(img, (int(resize_w), int(resize_h)))
  94. # return img, np.array([ori_h, ori_w])
  95. return img, [ratio_h, ratio_w]
  96. def resize_image_type0(self, img):
  97. """
  98. resize image to a size multiple of 32 which is required by the network
  99. args:
  100. img(array): array with shape [h, w, c]
  101. return(tuple):
  102. img, (ratio_h, ratio_w)
  103. """
  104. limit_side_len = self.limit_side_len
  105. h, w, c = img.shape
  106. # limit the max side
  107. if self.limit_type == 'max':
  108. if max(h, w) > limit_side_len:
  109. if h > w:
  110. ratio = float(limit_side_len) / h
  111. else:
  112. ratio = float(limit_side_len) / w
  113. else:
  114. ratio = 1.
  115. elif self.limit_type == 'min':
  116. if min(h, w) < limit_side_len:
  117. if h < w:
  118. ratio = float(limit_side_len) / h
  119. else:
  120. ratio = float(limit_side_len) / w
  121. else:
  122. ratio = 1.
  123. elif self.limit_type == 'resize_long':
  124. ratio = float(limit_side_len) / max(h, w)
  125. else:
  126. raise Exception('not support limit type, image ')
  127. resize_h = int(h * ratio)
  128. resize_w = int(w * ratio)
  129. resize_h = max(int(round(resize_h / 32) * 32), 32)
  130. resize_w = max(int(round(resize_w / 32) * 32), 32)
  131. try:
  132. if int(resize_w) <= 0 or int(resize_h) <= 0:
  133. return None, (None, None)
  134. img = cv2.resize(img, (int(resize_w), int(resize_h)))
  135. except:
  136. logging.info(img.shape, resize_w, resize_h)
  137. sys.exit(0)
  138. ratio_h = resize_h / float(h)
  139. ratio_w = resize_w / float(w)
  140. return img, [ratio_h, ratio_w]
  141. def resize_image_type2(self, img):
  142. """ resize image size """
  143. h, w, _ = img.shape
  144. resize_w = w
  145. resize_h = h
  146. if resize_h > resize_w:
  147. ratio = float(self.resize_long) / resize_h
  148. else:
  149. ratio = float(self.resize_long) / resize_w
  150. resize_h = int(resize_h * ratio)
  151. resize_w = int(resize_w * ratio)
  152. max_stride = 128
  153. resize_h = (resize_h + max_stride - 1) // max_stride * max_stride
  154. resize_w = (resize_w + max_stride - 1) // max_stride * max_stride
  155. img = cv2.resize(img, (int(resize_w), int(resize_h)))
  156. ratio_h = resize_h / float(h)
  157. ratio_w = resize_w / float(w)
  158. return img, [ratio_h, ratio_w]
  159. class NormalizeImage(BaseTransform):
  160. """ normalize image such as substract mean, divide std
  161. """
  162. def __init__(self, scale=None, mean=None, std=None, order='chw', **kwargs):
  163. if isinstance(scale, str):
  164. scale = eval(scale)
  165. self.scale = np.float32(scale if scale is not None else 1.0 / 255.0)
  166. mean = mean if mean is not None else [0.485, 0.456, 0.406]
  167. std = std if std is not None else [0.229, 0.224, 0.225]
  168. shape = (3, 1, 1) if order == 'chw' else (1, 1, 3)
  169. self.mean = np.array(mean).reshape(shape).astype('float32')
  170. self.std = np.array(std).reshape(shape).astype('float32')
  171. def apply(self, data):
  172. """ apply """
  173. img = data[K.IMAGE]
  174. from PIL import Image
  175. if isinstance(img, Image.Image):
  176. img = np.array(img)
  177. assert isinstance(img,
  178. np.ndarray), "invalid input 'img' in NormalizeImage"
  179. data[K.IMAGE] = (
  180. img.astype('float32') * self.scale - self.mean) / self.std
  181. return data
  182. @classmethod
  183. def get_input_keys(cls):
  184. """ get input keys """
  185. return [K.IMAGE]
  186. @classmethod
  187. def get_output_keys(cls):
  188. """ get output keys """
  189. return [K.IMAGE]
  190. class DBPostProcess(BaseTransform):
  191. """
  192. The post process for Differentiable Binarization (DB).
  193. """
  194. def __init__(self,
  195. thresh=0.3,
  196. box_thresh=0.7,
  197. max_candidates=1000,
  198. unclip_ratio=2.0,
  199. use_dilation=False,
  200. score_mode="fast",
  201. box_type='quad',
  202. **kwargs):
  203. self.thresh = thresh
  204. self.box_thresh = box_thresh
  205. self.max_candidates = max_candidates
  206. self.unclip_ratio = unclip_ratio
  207. self.min_size = 3
  208. self.score_mode = score_mode
  209. self.box_type = box_type
  210. assert score_mode in [
  211. "slow", "fast"
  212. ], "Score mode must be in [slow, fast] but got: {}".format(score_mode)
  213. self.dilation_kernel = None if not use_dilation else np.array([[1, 1],
  214. [1, 1]])
  215. def polygons_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
  216. """ _bitmap: single map with shape (1, H, W), whose values are binarized as {0, 1} """
  217. bitmap = _bitmap
  218. height, width = bitmap.shape
  219. boxes = []
  220. scores = []
  221. contours, _ = cv2.findContours((bitmap * 255).astype(np.uint8),
  222. cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
  223. for contour in contours[:self.max_candidates]:
  224. epsilon = 0.002 * cv2.arcLength(contour, True)
  225. approx = cv2.approxPolyDP(contour, epsilon, True)
  226. points = approx.reshape((-1, 2))
  227. if points.shape[0] < 4:
  228. continue
  229. score = self.box_score_fast(pred, points.reshape(-1, 2))
  230. if self.box_thresh > score:
  231. continue
  232. if points.shape[0] > 2:
  233. box = self.unclip(points, self.unclip_ratio)
  234. if len(box) > 1:
  235. continue
  236. else:
  237. continue
  238. box = box.reshape(-1, 2)
  239. _, sside = self.get_mini_boxes(box.reshape((-1, 1, 2)))
  240. if sside < self.min_size + 2:
  241. continue
  242. box = np.array(box)
  243. box[:, 0] = np.clip(
  244. np.round(box[:, 0] / width * dest_width), 0, dest_width)
  245. box[:, 1] = np.clip(
  246. np.round(box[:, 1] / height * dest_height), 0, dest_height)
  247. boxes.append(box.tolist())
  248. scores.append(score)
  249. return boxes, scores
  250. def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
  251. """ _bitmap: single map with shape (1, H, W), whose values are binarized as {0, 1} """
  252. bitmap = _bitmap
  253. height, width = bitmap.shape
  254. outs = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST,
  255. cv2.CHAIN_APPROX_SIMPLE)
  256. if len(outs) == 3:
  257. img, contours, _ = outs[0], outs[1], outs[2]
  258. elif len(outs) == 2:
  259. contours, _ = outs[0], outs[1]
  260. num_contours = min(len(contours), self.max_candidates)
  261. boxes = []
  262. scores = []
  263. for index in range(num_contours):
  264. contour = contours[index]
  265. points, sside = self.get_mini_boxes(contour)
  266. if sside < self.min_size:
  267. continue
  268. points = np.array(points)
  269. if self.score_mode == "fast":
  270. score = self.box_score_fast(pred, points.reshape(-1, 2))
  271. else:
  272. score = self.box_score_slow(pred, contour)
  273. if self.box_thresh > score:
  274. continue
  275. box = self.unclip(points, self.unclip_ratio).reshape(-1, 1, 2)
  276. box, sside = self.get_mini_boxes(box)
  277. if sside < self.min_size + 2:
  278. continue
  279. box = np.array(box)
  280. box[:, 0] = np.clip(
  281. np.round(box[:, 0] / width * dest_width), 0, dest_width)
  282. box[:, 1] = np.clip(
  283. np.round(box[:, 1] / height * dest_height), 0, dest_height)
  284. boxes.append(box.astype(np.int16))
  285. scores.append(score)
  286. return np.array(boxes, dtype=np.int16), scores
  287. def unclip(self, box, unclip_ratio):
  288. """ unclip """
  289. poly = Polygon(box)
  290. distance = poly.area * unclip_ratio / poly.length
  291. offset = pyclipper.PyclipperOffset()
  292. offset.AddPath(box, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
  293. expanded = np.array(offset.Execute(distance))
  294. return expanded
  295. def get_mini_boxes(self, contour):
  296. """ get mini boxes """
  297. bounding_box = cv2.minAreaRect(contour)
  298. points = sorted(list(cv2.boxPoints(bounding_box)), key=lambda x: x[0])
  299. index_1, index_2, index_3, index_4 = 0, 1, 2, 3
  300. if points[1][1] > points[0][1]:
  301. index_1 = 0
  302. index_4 = 1
  303. else:
  304. index_1 = 1
  305. index_4 = 0
  306. if points[3][1] > points[2][1]:
  307. index_2 = 2
  308. index_3 = 3
  309. else:
  310. index_2 = 3
  311. index_3 = 2
  312. box = [
  313. points[index_1], points[index_2], points[index_3], points[index_4]
  314. ]
  315. return box, min(bounding_box[1])
  316. def box_score_fast(self, bitmap, _box):
  317. """ box_score_fast: use bbox mean score as the mean score """
  318. h, w = bitmap.shape[:2]
  319. box = _box.copy()
  320. xmin = np.clip(np.floor(box[:, 0].min()).astype("int"), 0, w - 1)
  321. xmax = np.clip(np.ceil(box[:, 0].max()).astype("int"), 0, w - 1)
  322. ymin = np.clip(np.floor(box[:, 1].min()).astype("int"), 0, h - 1)
  323. ymax = np.clip(np.ceil(box[:, 1].max()).astype("int"), 0, h - 1)
  324. mask = np.zeros((ymax - ymin + 1, xmax - xmin + 1), dtype=np.uint8)
  325. box[:, 0] = box[:, 0] - xmin
  326. box[:, 1] = box[:, 1] - ymin
  327. cv2.fillPoly(mask, box.reshape(1, -1, 2).astype(np.int32), 1)
  328. return cv2.mean(bitmap[ymin:ymax + 1, xmin:xmax + 1], mask)[0]
  329. def box_score_slow(self, bitmap, contour):
  330. """ box_score_slow: use polyon mean score as the mean score """
  331. h, w = bitmap.shape[:2]
  332. contour = contour.copy()
  333. contour = np.reshape(contour, (-1, 2))
  334. xmin = np.clip(np.min(contour[:, 0]), 0, w - 1)
  335. xmax = np.clip(np.max(contour[:, 0]), 0, w - 1)
  336. ymin = np.clip(np.min(contour[:, 1]), 0, h - 1)
  337. ymax = np.clip(np.max(contour[:, 1]), 0, h - 1)
  338. mask = np.zeros((ymax - ymin + 1, xmax - xmin + 1), dtype=np.uint8)
  339. contour[:, 0] = contour[:, 0] - xmin
  340. contour[:, 1] = contour[:, 1] - ymin
  341. cv2.fillPoly(mask, contour.reshape(1, -1, 2).astype(np.int32), 1)
  342. return cv2.mean(bitmap[ymin:ymax + 1, xmin:xmax + 1], mask)[0]
  343. def apply(self, data):
  344. """ apply """
  345. pred = data[K.PROB_MAP]
  346. shape_list = [data[K.SHAPE]]
  347. pred = pred[0][:, 0, :, :]
  348. segmentation = pred > self.thresh
  349. boxes_batch = []
  350. for batch_index in range(pred.shape[0]):
  351. src_h, src_w, ratio_h, ratio_w = shape_list[batch_index]
  352. if self.dilation_kernel is not None:
  353. mask = cv2.dilate(
  354. np.array(segmentation[batch_index]).astype(np.uint8),
  355. self.dilation_kernel)
  356. else:
  357. mask = segmentation[batch_index]
  358. if self.box_type == 'poly':
  359. boxes, scores = self.polygons_from_bitmap(pred[batch_index],
  360. mask, src_w, src_h)
  361. elif self.box_type == 'quad':
  362. boxes, scores = self.boxes_from_bitmap(pred[batch_index], mask,
  363. src_w, src_h)
  364. else:
  365. raise ValueError("box_type can only be one of ['quad', 'poly']")
  366. data[K.DT_POLYS] = boxes
  367. data[K.DT_SCORES] = scores
  368. return data
  369. @classmethod
  370. def get_input_keys(cls):
  371. """ get input keys """
  372. return [K.PROB_MAP]
  373. @classmethod
  374. def get_output_keys(cls):
  375. """ get output keys """
  376. return [K.DT_POLYS, K.DT_SCORES]
  377. class CropByPolys(BaseTransform):
  378. """Crop Image by Polys
  379. """
  380. def __init__(self, det_box_type='quad'):
  381. super().__init__()
  382. self.det_box_type = det_box_type
  383. def apply(self, data):
  384. """ apply """
  385. ori_im = data[K.ORI_IM]
  386. # TODO
  387. # dt_boxes = self.sorted_boxes(data[K.DT_POLYS])
  388. dt_boxes = np.array(data[K.DT_POLYS])
  389. img_crop_list = []
  390. for bno in range(len(dt_boxes)):
  391. tmp_box = copy.deepcopy(dt_boxes[bno])
  392. if self.det_box_type == "quad":
  393. img_crop = self.get_rotate_crop_image(ori_im, tmp_box)
  394. else:
  395. img_crop = self.get_minarea_rect_crop(ori_im, tmp_box)
  396. img_crop_list.append(img_crop)
  397. data[K.SUB_IMGS] = img_crop_list
  398. return data
  399. @classmethod
  400. def get_input_keys(cls):
  401. """ get input keys """
  402. return [K.IM_PATH, K.DT_POLYS]
  403. @classmethod
  404. def get_output_keys(cls):
  405. """ get output keys """
  406. return [K.SUB_IMGS]
  407. def sorted_boxes(self, dt_boxes):
  408. """
  409. Sort text boxes in order from top to bottom, left to right
  410. args:
  411. dt_boxes(array):detected text boxes with shape [4, 2]
  412. return:
  413. sorted boxes(array) with shape [4, 2]
  414. """
  415. dt_boxes = np.array(dt_boxes)
  416. num_boxes = dt_boxes.shape[0]
  417. sorted_boxes = sorted(dt_boxes, key=lambda x: (x[0][1], x[0][0]))
  418. _boxes = list(sorted_boxes)
  419. for i in range(num_boxes - 1):
  420. for j in range(i, -1, -1):
  421. if abs(_boxes[j + 1][0][1] - _boxes[j][0][1]) < 10 and (
  422. _boxes[j + 1][0][0] < _boxes[j][0][0]):
  423. tmp = _boxes[j]
  424. _boxes[j] = _boxes[j + 1]
  425. _boxes[j + 1] = tmp
  426. else:
  427. break
  428. return _boxes
  429. def get_minarea_rect_crop(self, img, points):
  430. """get_minarea_rect_crop
  431. """
  432. bounding_box = cv2.minAreaRect(np.array(points).astype(np.int32))
  433. points = sorted(list(cv2.boxPoints(bounding_box)), key=lambda x: x[0])
  434. index_a, index_b, index_c, index_d = 0, 1, 2, 3
  435. if points[1][1] > points[0][1]:
  436. index_a = 0
  437. index_d = 1
  438. else:
  439. index_a = 1
  440. index_d = 0
  441. if points[3][1] > points[2][1]:
  442. index_b = 2
  443. index_c = 3
  444. else:
  445. index_b = 3
  446. index_c = 2
  447. box = [
  448. points[index_a], points[index_b], points[index_c], points[index_d]
  449. ]
  450. crop_img = self.get_rotate_crop_image(img, np.array(box))
  451. return crop_img
  452. def get_rotate_crop_image(self, img, points):
  453. """
  454. img_height, img_width = img.shape[0:2]
  455. left = int(np.min(points[:, 0]))
  456. right = int(np.max(points[:, 0]))
  457. top = int(np.min(points[:, 1]))
  458. bottom = int(np.max(points[:, 1]))
  459. img_crop = img[top:bottom, left:right, :].copy()
  460. points[:, 0] = points[:, 0] - left
  461. points[:, 1] = points[:, 1] - top
  462. """
  463. assert len(points) == 4, "shape of points must be 4*2"
  464. img_crop_width = int(
  465. max(
  466. np.linalg.norm(points[0] - points[1]),
  467. np.linalg.norm(points[2] - points[3])))
  468. img_crop_height = int(
  469. max(
  470. np.linalg.norm(points[0] - points[3]),
  471. np.linalg.norm(points[1] - points[2])))
  472. pts_std = np.float32([
  473. [0, 0],
  474. [img_crop_width, 0],
  475. [img_crop_width, img_crop_height],
  476. [0, img_crop_height],
  477. ])
  478. M = cv2.getPerspectiveTransform(points, pts_std)
  479. dst_img = cv2.warpPerspective(
  480. img,
  481. M,
  482. (img_crop_width, img_crop_height),
  483. borderMode=cv2.BORDER_REPLICATE,
  484. flags=cv2.INTER_CUBIC, )
  485. dst_img_height, dst_img_width = dst_img.shape[0:2]
  486. if dst_img_height * 1.0 / dst_img_width >= 1.5:
  487. dst_img = np.rot90(dst_img)
  488. return dst_img
  489. class SaveTextDetResults(BaseTransform):
  490. """ Save Text Det Results """
  491. def __init__(self, save_dir):
  492. super().__init__()
  493. self.save_dir = save_dir
  494. # We use pillow backend to save both numpy arrays and PIL Image objects
  495. self._writer = ImageWriter(backend='opencv')
  496. def apply(self, data):
  497. """ apply """
  498. if self.save_dir is None:
  499. logging.warning(
  500. "The `save_dir` has been set to None, so the text detection result won't to be saved."
  501. )
  502. return data
  503. fn = os.path.basename(data['input_path'])
  504. save_path = os.path.join(self.save_dir, fn)
  505. bbox_res = data[K.DT_POLYS]
  506. vis_img = self.draw_rectangle(data[K.IM_PATH], bbox_res)
  507. self._writer.write(save_path, vis_img)
  508. return data
  509. @classmethod
  510. def get_input_keys(cls):
  511. """ get input keys """
  512. return [K.IM_PATH, K.DT_POLYS, K.DT_SCORES]
  513. @classmethod
  514. def get_output_keys(cls):
  515. """ get output keys """
  516. return []
  517. def draw_rectangle(self, img_path, boxes):
  518. """ draw rectangle """
  519. boxes = np.array(boxes)
  520. img = cv2.imread(img_path)
  521. img_show = img.copy()
  522. for box in boxes.astype(int):
  523. box = np.reshape(np.array(box), [-1, 1, 2]).astype(np.int64)
  524. cv2.polylines(img_show, [box], True, (0, 0, 255), 2)
  525. return img_show
  526. class PrintResult(BaseTransform):
  527. """ Print Result Transform """
  528. def apply(self, data):
  529. """ apply """
  530. logging.info("The prediction result is:")
  531. logging.info(data[K.DT_POLYS])
  532. return data
  533. @classmethod
  534. def get_input_keys(cls):
  535. """ get input keys """
  536. return [K.DT_SCORES]
  537. @classmethod
  538. def get_output_keys(cls):
  539. """ get output keys """
  540. return []
  541. # DT_SCORES = 'dt_scores'
  542. # DT_POLYS = 'dt_polys'