test_table_structure_recognition.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import pytest
  2. from paddleocr import TableStructureRecognition
  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 table_structure_recognition_predictor():
  10. return TableStructureRecognition()
  11. @pytest.mark.parametrize(
  12. "image_path",
  13. [
  14. TEST_DATA_DIR / "table.jpg",
  15. ],
  16. )
  17. def test_predict(table_structure_recognition_predictor, image_path):
  18. result = table_structure_recognition_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. "bbox",
  25. "structure",
  26. "structure_score",
  27. }
  28. @pytest.mark.parametrize(
  29. "params",
  30. [
  31. {},
  32. ],
  33. )
  34. def test_predict_params(
  35. monkeypatch,
  36. table_structure_recognition_predictor,
  37. params,
  38. ):
  39. check_wrapper_simple_inference_param_forwarding(
  40. monkeypatch,
  41. table_structure_recognition_predictor,
  42. "paddlex_predictor",
  43. "dummy_path",
  44. params,
  45. )