pipeline.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. # Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
  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. from typing import Any, Dict, List, Optional, Tuple, Union
  15. import numpy as np
  16. from ....utils import logging
  17. from ....utils.deps import pipeline_requires_extra
  18. from ...common.batch_sampler import ImageBatchSampler
  19. from ...common.reader import ReadImage
  20. from ...models.object_detection.result import DetResult
  21. from ...utils.hpi import HPIConfig
  22. from ...utils.pp_option import PaddlePredictorOption
  23. from .._parallel import AutoParallelImageSimpleInferencePipeline
  24. from ..base import BasePipeline
  25. from ..components import CropByBoxes
  26. from ..ocr.result import OCRResult
  27. from .result import LayoutParsingResult
  28. from .utils import get_sub_regions_ocr_res, sorted_layout_boxes
  29. class _LayoutParsingPipeline(BasePipeline):
  30. """Layout Parsing Pipeline"""
  31. def __init__(
  32. self,
  33. config: Dict,
  34. device: str = None,
  35. pp_option: PaddlePredictorOption = None,
  36. use_hpip: bool = False,
  37. hpi_config: Optional[Union[Dict[str, Any], HPIConfig]] = None,
  38. ) -> None:
  39. """Initializes the layout parsing pipeline.
  40. Args:
  41. config (Dict): Configuration dictionary containing various settings.
  42. device (str, optional): Device to run the predictions on. Defaults to None.
  43. pp_option (PaddlePredictorOption, optional): PaddlePredictor options. Defaults to None.
  44. use_hpip (bool, optional): Whether to use the high-performance
  45. inference plugin (HPIP) by default. Defaults to False.
  46. hpi_config (Optional[Union[Dict[str, Any], HPIConfig]], optional):
  47. The default high-performance inference configuration dictionary.
  48. Defaults to None.
  49. """
  50. super().__init__(
  51. device=device, pp_option=pp_option, use_hpip=use_hpip, hpi_config=hpi_config
  52. )
  53. self.inintial_predictor(config)
  54. self.batch_sampler = ImageBatchSampler(batch_size=1)
  55. self.img_reader = ReadImage(format="BGR")
  56. self._crop_by_boxes = CropByBoxes()
  57. def inintial_predictor(self, config: Dict) -> None:
  58. """Initializes the predictor based on the provided configuration.
  59. Args:
  60. config (Dict): A dictionary containing the configuration for the predictor.
  61. Returns:
  62. None
  63. """
  64. self.use_doc_preprocessor = config.get("use_doc_preprocessor", True)
  65. self.use_table_recognition = config.get("use_table_recognition", True)
  66. self.use_seal_recognition = config.get("use_seal_recognition", True)
  67. self.use_formula_recognition = config.get("use_formula_recognition", True)
  68. if self.use_doc_preprocessor:
  69. doc_preprocessor_config = config.get("SubPipelines", {}).get(
  70. "DocPreprocessor",
  71. {
  72. "pipeline_config_error": "config error for doc_preprocessor_pipeline!"
  73. },
  74. )
  75. self.doc_preprocessor_pipeline = self.create_pipeline(
  76. doc_preprocessor_config
  77. )
  78. layout_det_config = config.get("SubModules", {}).get(
  79. "LayoutDetection",
  80. {"model_config_error": "config error for layout_det_model!"},
  81. )
  82. layout_kwargs = {}
  83. if (threshold := layout_det_config.get("threshold", None)) is not None:
  84. layout_kwargs["threshold"] = threshold
  85. if (layout_nms := layout_det_config.get("layout_nms", None)) is not None:
  86. layout_kwargs["layout_nms"] = layout_nms
  87. if (
  88. layout_unclip_ratio := layout_det_config.get("layout_unclip_ratio", None)
  89. ) is not None:
  90. layout_kwargs["layout_unclip_ratio"] = layout_unclip_ratio
  91. if (
  92. layout_merge_bboxes_mode := layout_det_config.get(
  93. "layout_merge_bboxes_mode", None
  94. )
  95. ) is not None:
  96. layout_kwargs["layout_merge_bboxes_mode"] = layout_merge_bboxes_mode
  97. self.layout_det_model = self.create_model(layout_det_config, **layout_kwargs)
  98. general_ocr_config = config.get("SubPipelines", {}).get(
  99. "GeneralOCR",
  100. {"pipeline_config_error": "config error for general_ocr_pipeline!"},
  101. )
  102. self.general_ocr_pipeline = self.create_pipeline(general_ocr_config)
  103. if self.use_seal_recognition:
  104. seal_recognition_config = config.get("SubPipelines", {}).get(
  105. "SealRecognition",
  106. {
  107. "pipeline_config_error": "config error for seal_recognition_pipeline!"
  108. },
  109. )
  110. self.seal_recognition_pipeline = self.create_pipeline(
  111. seal_recognition_config
  112. )
  113. if self.use_table_recognition:
  114. table_recognition_config = config.get("SubPipelines", {}).get(
  115. "TableRecognition",
  116. {
  117. "pipeline_config_error": "config error for table_recognition_pipeline!"
  118. },
  119. )
  120. self.table_recognition_pipeline = self.create_pipeline(
  121. table_recognition_config
  122. )
  123. if self.use_formula_recognition:
  124. formula_recognition_config = config.get("SubPipelines", {}).get(
  125. "FormulaRecognition",
  126. {
  127. "pipeline_config_error": "config error for formula_recognition_pipeline!"
  128. },
  129. )
  130. self.formula_recognition_pipeline = self.create_pipeline(
  131. formula_recognition_config
  132. )
  133. return
  134. def get_layout_parsing_res(
  135. self,
  136. image: list,
  137. layout_det_res: DetResult,
  138. overall_ocr_res: OCRResult,
  139. table_res_list: list,
  140. seal_res_list: list,
  141. formula_res_list: list,
  142. text_det_limit_side_len: Optional[int] = None,
  143. text_det_limit_type: Optional[str] = None,
  144. text_det_thresh: Optional[float] = None,
  145. text_det_box_thresh: Optional[float] = None,
  146. text_det_unclip_ratio: Optional[float] = None,
  147. text_rec_score_thresh: Optional[float] = None,
  148. ) -> list:
  149. """
  150. Retrieves the layout parsing result based on the layout detection result, OCR result, and other recognition results.
  151. Args:
  152. image (list): The input image.
  153. layout_det_res (DetResult): The detection result containing the layout information of the document.
  154. overall_ocr_res (OCRResult): The overall OCR result containing text information.
  155. table_res_list (list): A list of table recognition results.
  156. seal_res_list (list): A list of seal recognition results.
  157. formula_res_list (list): A list of formula recognition results.
  158. text_det_limit_side_len (Optional[int], optional): The maximum side length of the text detection region. Defaults to None.
  159. text_det_limit_type (Optional[str], optional): The type of limit for the text detection region. Defaults to None.
  160. text_det_thresh (Optional[float], optional): The confidence threshold for text detection. Defaults to None.
  161. text_det_box_thresh (Optional[float], optional): The confidence threshold for text detection bounding boxes. Defaults to None
  162. text_det_unclip_ratio (Optional[float], optional): The unclip ratio for text detection. Defaults to None.
  163. text_rec_score_thresh (Optional[float], optional): The score threshold for text recognition. Defaults to None.
  164. Returns:
  165. list: A list of dictionaries representing the layout parsing result.
  166. """
  167. layout_parsing_res = []
  168. matched_ocr_dict = {}
  169. formula_index = 0
  170. table_index = 0
  171. seal_index = 0
  172. image = np.array(image)
  173. object_boxes = []
  174. for object_box_idx, box_info in enumerate(layout_det_res["boxes"]):
  175. single_box_res = {}
  176. box = box_info["coordinate"]
  177. label = box_info["label"].lower()
  178. single_box_res["block_bbox"] = box
  179. single_box_res["block_label"] = label
  180. single_box_res["block_content"] = ""
  181. object_boxes.append(box)
  182. if label == "formula":
  183. if len(formula_res_list) > 0:
  184. assert (
  185. len(formula_res_list) > formula_index
  186. ), f"The number of \
  187. formula regions of layout parsing pipeline \
  188. and formula recognition pipeline are different!"
  189. single_box_res["block_content"] = formula_res_list[formula_index][
  190. "rec_formula"
  191. ]
  192. formula_index += 1
  193. elif label == "table":
  194. if len(table_res_list) > 0:
  195. assert (
  196. len(table_res_list) > table_index
  197. ), f"The number of \
  198. table regions of layout parsing pipeline \
  199. and table recognition pipeline are different!"
  200. single_box_res["block_content"] = table_res_list[table_index][
  201. "pred_html"
  202. ]
  203. table_index += 1
  204. elif label == "seal":
  205. if len(seal_res_list) > 0:
  206. assert (
  207. len(seal_res_list) > seal_index
  208. ), f"The number of \
  209. seal regions of layout parsing pipeline \
  210. and seal recognition pipeline are different!"
  211. single_box_res["block_content"] = ", ".join(
  212. seal_res_list[seal_index]["rec_texts"]
  213. )
  214. seal_index += 1
  215. else:
  216. ocr_res_in_box, matched_idxes = get_sub_regions_ocr_res(
  217. overall_ocr_res, [box], return_match_idx=True
  218. )
  219. for matched_idx in matched_idxes:
  220. if matched_ocr_dict.get(matched_idx, None) is None:
  221. matched_ocr_dict[matched_idx] = [object_box_idx]
  222. else:
  223. matched_ocr_dict[matched_idx].append(object_box_idx)
  224. single_box_res["block_content"] = "\n".join(ocr_res_in_box["rec_texts"])
  225. layout_parsing_res.append(single_box_res)
  226. for layout_box_ids in matched_ocr_dict.values():
  227. # one ocr is matched to multiple layout boxes, split the text into multiple lines
  228. if len(layout_box_ids) > 1:
  229. for idx in layout_box_ids:
  230. wht_im = np.ones(image.shape, dtype=image.dtype) * 255
  231. box = layout_parsing_res[idx]["block_bbox"]
  232. x1, y1, x2, y2 = [int(i) for i in box]
  233. wht_im[y1:y2, x1:x2, :] = image[y1:y2, x1:x2, :]
  234. sub_ocr_res = next(
  235. self.general_ocr_pipeline(
  236. wht_im,
  237. text_det_limit_side_len=text_det_limit_side_len,
  238. text_det_limit_type=text_det_limit_type,
  239. text_det_thresh=text_det_thresh,
  240. text_det_box_thresh=text_det_box_thresh,
  241. text_det_unclip_ratio=text_det_unclip_ratio,
  242. text_rec_score_thresh=text_rec_score_thresh,
  243. )
  244. )
  245. layout_parsing_res[idx]["block_content"] = "\n".join(
  246. sub_ocr_res["rec_texts"]
  247. )
  248. ocr_without_layout_boxes = get_sub_regions_ocr_res(
  249. overall_ocr_res, object_boxes, flag_within=False
  250. )
  251. for ocr_rec_box, ocr_rec_text in zip(
  252. ocr_without_layout_boxes["rec_boxes"], ocr_without_layout_boxes["rec_texts"]
  253. ):
  254. single_box_res = {}
  255. single_box_res["block_bbox"] = ocr_rec_box
  256. single_box_res["block_label"] = "other_text"
  257. single_box_res["block_content"] = ocr_rec_text
  258. layout_parsing_res.append(single_box_res)
  259. layout_parsing_res = sorted_layout_boxes(layout_parsing_res, w=image.shape[1])
  260. return layout_parsing_res
  261. def check_model_settings_valid(self, input_params: Dict) -> bool:
  262. """
  263. Check if the input parameters are valid based on the initialized models.
  264. Args:
  265. input_params (Dict): A dictionary containing input parameters.
  266. Returns:
  267. bool: True if all required models are initialized according to input parameters, False otherwise.
  268. """
  269. if input_params["use_doc_preprocessor"] and not self.use_doc_preprocessor:
  270. logging.error(
  271. "Set use_doc_preprocessor, but the models for doc preprocessor are not initialized."
  272. )
  273. return False
  274. if input_params["use_seal_recognition"] and not self.use_seal_recognition:
  275. logging.error(
  276. "Set use_seal_recognition, but the models for seal recognition are not initialized."
  277. )
  278. return False
  279. if input_params["use_table_recognition"] and not self.use_table_recognition:
  280. logging.error(
  281. "Set use_table_recognition, but the models for table recognition are not initialized."
  282. )
  283. return False
  284. return True
  285. def get_model_settings(
  286. self,
  287. use_doc_orientation_classify: Optional[bool],
  288. use_doc_unwarping: Optional[bool],
  289. use_seal_recognition: Optional[bool],
  290. use_table_recognition: Optional[bool],
  291. use_formula_recognition: Optional[bool],
  292. ) -> dict:
  293. """
  294. Get the model settings based on the provided parameters or default values.
  295. Args:
  296. use_doc_orientation_classify (Optional[bool]): Whether to use document orientation classification.
  297. use_doc_unwarping (Optional[bool]): Whether to use document unwarping.
  298. use_seal_recognition (Optional[bool]): Whether to use seal recognition.
  299. use_table_recognition (Optional[bool]): Whether to use table recognition.
  300. Returns:
  301. dict: A dictionary containing the model settings.
  302. """
  303. if use_doc_orientation_classify is None and use_doc_unwarping is None:
  304. use_doc_preprocessor = self.use_doc_preprocessor
  305. else:
  306. if use_doc_orientation_classify is True or use_doc_unwarping is True:
  307. use_doc_preprocessor = True
  308. else:
  309. use_doc_preprocessor = False
  310. if use_seal_recognition is None:
  311. use_seal_recognition = self.use_seal_recognition
  312. if use_table_recognition is None:
  313. use_table_recognition = self.use_table_recognition
  314. if use_formula_recognition is None:
  315. use_formula_recognition = self.use_formula_recognition
  316. return dict(
  317. use_doc_preprocessor=use_doc_preprocessor,
  318. use_seal_recognition=use_seal_recognition,
  319. use_table_recognition=use_table_recognition,
  320. use_formula_recognition=use_formula_recognition,
  321. )
  322. def predict(
  323. self,
  324. input: Union[str, List[str], np.ndarray, List[np.ndarray]],
  325. use_doc_orientation_classify: Optional[bool] = None,
  326. use_doc_unwarping: Optional[bool] = None,
  327. use_textline_orientation: Optional[bool] = None,
  328. use_seal_recognition: Optional[bool] = None,
  329. use_table_recognition: Optional[bool] = None,
  330. use_formula_recognition: Optional[bool] = None,
  331. layout_threshold: Optional[Union[float, dict]] = None,
  332. layout_nms: Optional[bool] = None,
  333. layout_unclip_ratio: Optional[Union[float, Tuple[float, float], dict]] = None,
  334. layout_merge_bboxes_mode: Optional[str] = None,
  335. text_det_limit_side_len: Optional[int] = None,
  336. text_det_limit_type: Optional[str] = None,
  337. text_det_thresh: Optional[float] = None,
  338. text_det_box_thresh: Optional[float] = None,
  339. text_det_unclip_ratio: Optional[float] = None,
  340. text_rec_score_thresh: Optional[float] = None,
  341. seal_det_limit_side_len: Optional[int] = None,
  342. seal_det_limit_type: Optional[str] = None,
  343. seal_det_thresh: Optional[float] = None,
  344. seal_det_box_thresh: Optional[float] = None,
  345. seal_det_unclip_ratio: Optional[float] = None,
  346. seal_rec_score_thresh: Optional[float] = None,
  347. **kwargs,
  348. ) -> LayoutParsingResult:
  349. """
  350. This function predicts the layout parsing result for the given input.
  351. Args:
  352. input (Union[str, list[str], np.ndarray, list[np.ndarray]]): The input image(s) or pdf(s) to be processed.
  353. use_doc_orientation_classify (Optional[bool]): Whether to use document orientation classification.
  354. use_doc_unwarping (Optional[bool]): Whether to use document unwarping.
  355. use_textline_orientation (Optional[bool]): Whether to use textline orientation prediction.
  356. use_seal_recognition (Optional[bool]): Whether to use seal recognition.
  357. use_table_recognition (Optional[bool]): Whether to use table recognition.
  358. use_formula_recognition (Optional[bool]): Whether to use formula recognition.
  359. layout_threshold (Optional[float]): The threshold value to filter out low-confidence predictions. Default is None.
  360. layout_nms (bool, optional): Whether to use layout-aware NMS. Defaults to False.
  361. layout_unclip_ratio (Optional[Union[float, Tuple[float, float]]], optional): The ratio of unclipping the bounding box.
  362. Defaults to None.
  363. If it's a single number, then both width and height are used.
  364. If it's a tuple of two numbers, then they are used separately for width and height respectively.
  365. If it's None, then no unclipping will be performed.
  366. layout_merge_bboxes_mode (Optional[str], optional): The mode for merging bounding boxes. Defaults to None.
  367. text_det_limit_side_len (Optional[int]): Maximum side length for text detection.
  368. text_det_limit_type (Optional[str]): Type of limit to apply for text detection.
  369. text_det_thresh (Optional[float]): Threshold for text detection.
  370. text_det_box_thresh (Optional[float]): Threshold for text detection boxes.
  371. text_det_unclip_ratio (Optional[float]): Ratio for unclipping text detection boxes.
  372. text_rec_score_thresh (Optional[float]): Score threshold for text recognition.
  373. seal_det_limit_side_len (Optional[int]): Maximum side length for seal detection.
  374. seal_det_limit_type (Optional[str]): Type of limit to apply for seal detection.
  375. seal_det_thresh (Optional[float]): Threshold for seal detection.
  376. seal_det_box_thresh (Optional[float]): Threshold for seal detection boxes.
  377. seal_det_unclip_ratio (Optional[float]): Ratio for unclipping seal detection boxes.
  378. seal_rec_score_thresh (Optional[float]): Score threshold for seal recognition.
  379. **kwargs: Additional keyword arguments.
  380. Returns:
  381. LayoutParsingResult: The predicted layout parsing result.
  382. """
  383. model_settings = self.get_model_settings(
  384. use_doc_orientation_classify,
  385. use_doc_unwarping,
  386. use_seal_recognition,
  387. use_table_recognition,
  388. use_formula_recognition,
  389. )
  390. if not self.check_model_settings_valid(model_settings):
  391. yield {"error": "the input params for model settings are invalid!"}
  392. for img_id, batch_data in enumerate(self.batch_sampler(input)):
  393. image_array = self.img_reader(batch_data.instances)[0]
  394. if model_settings["use_doc_preprocessor"]:
  395. doc_preprocessor_res = next(
  396. self.doc_preprocessor_pipeline(
  397. image_array,
  398. use_doc_orientation_classify=use_doc_orientation_classify,
  399. use_doc_unwarping=use_doc_unwarping,
  400. )
  401. )
  402. else:
  403. doc_preprocessor_res = {"output_img": image_array}
  404. doc_preprocessor_image = doc_preprocessor_res["output_img"]
  405. layout_det_res = next(
  406. self.layout_det_model(
  407. doc_preprocessor_image,
  408. threshold=layout_threshold,
  409. layout_nms=layout_nms,
  410. layout_unclip_ratio=layout_unclip_ratio,
  411. layout_merge_bboxes_mode=layout_merge_bboxes_mode,
  412. )
  413. )
  414. overall_ocr_res = next(
  415. self.general_ocr_pipeline(
  416. doc_preprocessor_image,
  417. use_textline_orientation=use_textline_orientation,
  418. text_det_limit_side_len=text_det_limit_side_len,
  419. text_det_limit_type=text_det_limit_type,
  420. text_det_thresh=text_det_thresh,
  421. text_det_box_thresh=text_det_box_thresh,
  422. text_det_unclip_ratio=text_det_unclip_ratio,
  423. text_rec_score_thresh=text_rec_score_thresh,
  424. )
  425. )
  426. if model_settings["use_table_recognition"]:
  427. table_res_all = next(
  428. self.table_recognition_pipeline(
  429. doc_preprocessor_image,
  430. use_doc_orientation_classify=False,
  431. use_doc_unwarping=False,
  432. use_layout_detection=False,
  433. use_ocr_model=False,
  434. overall_ocr_res=overall_ocr_res,
  435. layout_det_res=layout_det_res,
  436. )
  437. )
  438. table_res_list = table_res_all["table_res_list"]
  439. else:
  440. table_res_list = []
  441. if model_settings["use_seal_recognition"]:
  442. seal_res_all = next(
  443. self.seal_recognition_pipeline(
  444. doc_preprocessor_image,
  445. use_doc_orientation_classify=False,
  446. use_doc_unwarping=False,
  447. use_layout_detection=False,
  448. layout_det_res=layout_det_res,
  449. seal_det_limit_side_len=seal_det_limit_side_len,
  450. seal_det_limit_type=seal_det_limit_type,
  451. seal_det_thresh=seal_det_thresh,
  452. seal_det_box_thresh=seal_det_box_thresh,
  453. seal_det_unclip_ratio=seal_det_unclip_ratio,
  454. seal_rec_score_thresh=seal_rec_score_thresh,
  455. )
  456. )
  457. seal_res_list = seal_res_all["seal_res_list"]
  458. else:
  459. seal_res_list = []
  460. if model_settings["use_formula_recognition"]:
  461. formula_res_all = next(
  462. self.formula_recognition_pipeline(
  463. doc_preprocessor_image,
  464. use_layout_detection=False,
  465. use_doc_orientation_classify=False,
  466. use_doc_unwarping=False,
  467. layout_det_res=layout_det_res,
  468. )
  469. )
  470. formula_res_list = formula_res_all["formula_res_list"]
  471. else:
  472. formula_res_list = []
  473. parsing_res_list = self.get_layout_parsing_res(
  474. doc_preprocessor_image,
  475. layout_det_res=layout_det_res,
  476. overall_ocr_res=overall_ocr_res,
  477. table_res_list=table_res_list,
  478. seal_res_list=seal_res_list,
  479. formula_res_list=formula_res_list,
  480. text_det_limit_side_len=text_det_limit_side_len,
  481. text_det_limit_type=text_det_limit_type,
  482. text_det_thresh=text_det_thresh,
  483. text_det_box_thresh=text_det_box_thresh,
  484. text_det_unclip_ratio=text_det_unclip_ratio,
  485. text_rec_score_thresh=text_rec_score_thresh,
  486. )
  487. single_img_res = {
  488. "input_path": batch_data.input_paths[0],
  489. "page_index": batch_data.page_indexes[0],
  490. "doc_preprocessor_res": doc_preprocessor_res,
  491. "layout_det_res": layout_det_res,
  492. "overall_ocr_res": overall_ocr_res,
  493. "table_res_list": table_res_list,
  494. "seal_res_list": seal_res_list,
  495. "formula_res_list": formula_res_list,
  496. "parsing_res_list": parsing_res_list,
  497. "model_settings": model_settings,
  498. }
  499. yield LayoutParsingResult(single_img_res)
  500. @pipeline_requires_extra("ocr")
  501. class LayoutParsingPipeline(AutoParallelImageSimpleInferencePipeline):
  502. entities = ["layout_parsing"]
  503. @property
  504. def _pipeline_cls(self):
  505. return _LayoutParsingPipeline
  506. def _get_batch_size(self, config):
  507. return 1