mirror of
https://github.com/datalab-to/chandra.git
synced 2026-02-28 15:21:26 +00:00
Initial benchmarks
This commit is contained in:
10
tests/conftest.py
Normal file
10
tests/conftest.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def simple_text_image() -> Image.Image:
|
||||
image = Image.new("RGB", (800, 600), "white")
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.text((50, 50), "Hello, World!", fill="black", font_size=32)
|
||||
return image
|
||||
18
tests/integration/test_image_inference.py
Normal file
18
tests/integration/test_image_inference.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from chandra.model import InferenceManager, BatchInputItem
|
||||
|
||||
|
||||
def test_inference_image(simple_text_image):
|
||||
manager = InferenceManager(method="hf")
|
||||
batch = [
|
||||
BatchInputItem(
|
||||
image=simple_text_image,
|
||||
prompt_type="ocr_layout",
|
||||
)
|
||||
]
|
||||
outputs = manager.generate(batch, max_output_tokens=128)
|
||||
assert len(outputs) == 1
|
||||
output = outputs[0]
|
||||
assert "Hello, World!" in output.markdown
|
||||
|
||||
chunks = output.chunks
|
||||
assert len(chunks) == 1
|
||||
Reference in New Issue
Block a user