Skip to content

Commit

Permalink
Merge pull request #95 from VikParuchuri/dev
Browse files Browse the repository at this point in the history
Add batch size to OCR
  • Loading branch information
VikParuchuri authored May 8, 2024
2 parents 40a1043 + f97a834 commit 2133e3f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "surya-ocr"
version = "0.4.1"
version = "0.4.2"
description = "OCR, layout, reading order, and line detection in 90+ languages"
authors = ["Vik Paruchuri <[email protected]>"]
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions surya/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from surya.schema import TextLine, OCRResult


def run_recognition(images: List[Image.Image], langs: List[List[str]], rec_model, rec_processor, bboxes: List[List[List[int]]] = None, polygons: List[List[List[List[int]]]] = None) -> List[OCRResult]:
def run_recognition(images: List[Image.Image], langs: List[List[str]], rec_model, rec_processor, bboxes: List[List[List[int]]] = None, polygons: List[List[List[List[int]]]] = None, batch_size=None) -> List[OCRResult]:
# Polygons need to be in corner format - [[x1, y1], [x2, y2], [x3, y3], [x4, y4]], bboxes in [x1, y1, x2, y2] format
assert bboxes is not None or polygons is not None
assert len(images) == len(langs), "You need to pass in one list of languages for each image"
Expand All @@ -28,7 +28,7 @@ def run_recognition(images: List[Image.Image], langs: List[List[str]], rec_model
all_slices.extend(slices)
all_langs.extend([lang] * len(slices))

rec_predictions, _ = batch_recognition(all_slices, all_langs, rec_model, rec_processor)
rec_predictions, _ = batch_recognition(all_slices, all_langs, rec_model, rec_processor, batch_size=batch_size)

predictions_by_image = []
slice_start = 0
Expand Down

0 comments on commit 2133e3f

Please sign in to comment.