test_table_cells_detection.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import pytest
  2. from paddleocr import TableCellsDetection
  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 table_cells_detection_predictor():
  11. return TableCellsDetection()
  12. @pytest.mark.parametrize(
  13. "image_path",
  14. [
  15. TEST_DATA_DIR / "table.jpg",
  16. ],
  17. )
  18. def test_predict(table_cells_detection_predictor, image_path):
  19. result = table_cells_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. ],
  28. )
  29. def test_predict_params(
  30. monkeypatch,
  31. table_cells_detection_predictor,
  32. params,
  33. ):
  34. check_wrapper_simple_inference_param_forwarding(
  35. monkeypatch,
  36. table_cells_detection_predictor,
  37. "paddlex_predictor",
  38. "dummy_path",
  39. params,
  40. )