Fix bad test - Add real latex image
Some checks failed
Integration test / build (push) Has been cancelled
Unit tests / build (t4_gpu) (push) Has been cancelled
Unit tests / build (ubuntu-latest) (push) Has been cancelled
Unit tests / build (windows-latest) (push) Has been cancelled
Test CLI scripts / build (push) Has been cancelled

This commit is contained in:
Tarun Menta 2025-08-29 14:53:41 -04:00
parent e7ec40ecb4
commit d4496f8caa
No known key found for this signature in database
3 changed files with 10 additions and 6 deletions

BIN
tests/assets/test_latex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -79,3 +79,10 @@ def test_image_tall():
font_size=24,
)
return image
@pytest.fixture()
def test_image_latex():
assets_dir = os.path.join(os.path.dirname(__file__), "assets")
img_path = os.path.join(assets_dir, "test_latex.png")
image = Image.open(img_path).convert("RGB")
return image

View File

@ -6,13 +6,10 @@ from surya.common.surya.schema import TaskNames
from surya.recognition import OCRResult
def test_latex_ocr(recognition_predictor):
img = Image.new("RGB", (200, 100), color="white")
draw = ImageDraw.Draw(img)
draw.text((10, 10), "E = mc2", fill="black", font_size=48)
def test_latex_ocr(recognition_predictor, test_image_latex):
width, height = test_image_latex.size
results: List[OCRResult] = recognition_predictor(
[img], [TaskNames.block_without_boxes], bboxes=[[[0, 0, 200, 100]]]
[test_image_latex], [TaskNames.block_without_boxes], bboxes=[[[0, 0, width, height]]]
)
text = results[0].text_lines[0].text
assert len(results) == 1