Update README.md

This commit is contained in:
Odunayo Ogundepo
2025-12-25 19:56:41 +00:00
committed by system
parent 429e47146a
commit 4cfa60d5da

View File

@@ -202,3 +202,29 @@ def run_inference(model, processor, messages, max_new_tokens=128, device="cuda")
)
return outputs[0]
```
### End-to-End Example
```python
model = load_model("taresco/KarantaOCR")
processor = load_processor("taresco/KarantaOCR")
prompt = """Below is the image of one page of a PDF document.
Just return the plain text representation of this document as if you were reading it naturally.
Turn equations into a LaTeX representation, and tables into markdown format. Remove the headers and footers, but keep references and footnotes.
Read any natural handwriting.
This is likely one page out of several in the document, so be sure to preserve any sentences that come from the previous page, or continue onto the next page, exactly as they are.
If there is no text at all that you think you should read, you can output null.
if the document contains diacritics, please include them in the output.
Do not hallucinate.
"""
messages = build_message(
image_url="example.pdf",
system_prompt=prompt,
page=0
)
output_text = run_inference(model, processor, messages)
print(output_text)
```