-
Notifications
You must be signed in to change notification settings - Fork 651
Open
Description
Dear All,
this is the code on the repo for a quick start with chandra using python:
from chandra.model import InferenceManager
from chandra.input import load_pdf_images
manager = InferenceManager(method="hf")
images = load_pdf_images("document.pdf")
results = manager.generate(images)
print(results[0].markdown)
However, for me, this won't work.
(1) load_pdf_images - has a required argument page_range, which I had to set to []
(2) load_pdf_images - returns List[Image.Image], a list of PIL images, however process_batch_element in generate_hf requires the input items to be of type BatchInputItem.
So, I guess this can be slightly modified to this:
from chandra.model import InferenceManager
from chandra.input import load_pdf_images
from chandra.model.schema import BatchInputItem
manager = InferenceManager(method="hf")
images = load_pdf_images("Dolphin.pdf", page_range=[])
batch_inputs = [
BatchInputItem(
image=img,
prompt_type="ocr_layout"
)
for img in images
]
results = manager.generate(batch_inputs)
print(results[0].markdown)
Best,
Mario
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels