test_text_detection.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import pytest
  2. from paddleocr import TextDetection
  3. from ..testing_utils import (
  4. TEST_DATA_DIR,
  5. check_simple_inference_result,
  6. check_wrapper_simple_inference_param_forwarding,
  7. )
  8. @pytest.fixture(scope="module")
  9. def text_detection_predictor():
  10. return TextDetection()
  11. @pytest.mark.parametrize(
  12. "image_path",
  13. [
  14. TEST_DATA_DIR / "table.jpg",
  15. ],
  16. )
  17. def test_predict(text_detection_predictor, image_path):
  18. result = text_detection_predictor.predict(str(image_path))
  19. check_simple_inference_result(result)
  20. assert result[0].keys() == {
  21. "input_path",
  22. "page_index",
  23. "input_img",
  24. "dt_polys",
  25. "dt_scores",
  26. }
  27. @pytest.mark.parametrize(
  28. "params",
  29. [
  30. {"limit_side_len": 640, "limit_type": "min"},
  31. {"thresh": 0.5},
  32. {"box_thresh": 0.3},
  33. {"unclip_ratio": 3.0},
  34. ],
  35. )
  36. def test_predict_params(
  37. monkeypatch,
  38. text_detection_predictor,
  39. params,
  40. ):
  41. check_wrapper_simple_inference_param_forwarding(
  42. monkeypatch,
  43. text_detection_predictor,
  44. "paddlex_predictor",
  45. "dummy_path",
  46. params,
  47. )