test_doc_vlm.py 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import pytest
  2. from paddleocr import DocVLM
  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 doc_vlm_predictor():
  10. return DocVLM()
  11. @pytest.mark.resource_intensive
  12. @pytest.mark.parametrize(
  13. "image_path",
  14. [
  15. TEST_DATA_DIR / "medal_table.png",
  16. ],
  17. )
  18. def test_predict(doc_vlm_predictor, image_path):
  19. result = doc_vlm_predictor.predict(str(image_path))
  20. check_simple_inference_result(result)
  21. assert result[0].keys() == {
  22. "input_path",
  23. "page_index",
  24. "input_img",
  25. "result",
  26. }
  27. @pytest.mark.resource_intensive
  28. @pytest.mark.parametrize(
  29. "params",
  30. [
  31. {},
  32. ],
  33. )
  34. def test_predict_params(
  35. monkeypatch,
  36. doc_vlm_predictor,
  37. params,
  38. ):
  39. check_wrapper_simple_inference_param_forwarding(
  40. monkeypatch,
  41. doc_vlm_predictor,
  42. "paddlex_predictor",
  43. "dummy_path",
  44. params,
  45. )