test_layout_detection.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import pytest
  2. from paddleocr import LayoutDetection
  3. from ..testing_utils import (
  4. TEST_DATA_DIR,
  5. check_simple_inference_result,
  6. check_wrapper_simple_inference_param_forwarding,
  7. )
  8. from .object_detection_common import check_result_item_keys
  9. @pytest.fixture(scope="module")
  10. def layout_detection_predictor():
  11. return LayoutDetection()
  12. @pytest.mark.parametrize(
  13. "image_path",
  14. [
  15. TEST_DATA_DIR / "doc_with_formula.png",
  16. ],
  17. )
  18. def test_predict(layout_detection_predictor, image_path):
  19. result = layout_detection_predictor.predict(str(image_path))
  20. check_simple_inference_result(result)
  21. check_result_item_keys(result[0])
  22. @pytest.mark.parametrize(
  23. "params",
  24. [
  25. {"img_size": 640},
  26. {"threshold": 0.5},
  27. {"layout_nms": True},
  28. {"layout_unclip_ratio": True},
  29. {"layout_merge_bboxes_mode": True},
  30. ],
  31. )
  32. def test_predict_params(
  33. monkeypatch,
  34. layout_detection_predictor,
  35. params,
  36. ):
  37. check_wrapper_simple_inference_param_forwarding(
  38. monkeypatch,
  39. layout_detection_predictor,
  40. "paddlex_predictor",
  41. "dummy_path",
  42. params,
  43. )