Skip to content

Commit aa8ee5a

Browse files
authored
Merge pull request #289 from VikParuchuri/dev
Patch cli script issue
2 parents d9213c8 + 1d233ce commit aa8ee5a

File tree

7 files changed

+9
-6
lines changed

7 files changed

+9
-6
lines changed

.github/workflows/scripts.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ jobs:
3030
run: poetry run surya_layout benchmark_data/pdfs/switch_trans.pdf --page_range 0
3131
- name: Test table
3232
run: poetry run surya_table benchmark_data/pdfs/switch_trans.pdf --page_range 0
33+
- name: Test detection folder
34+
run: poetry run surya_detect benchmark_data/pdfs --page_range 0

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "surya-ocr"
3-
version = "0.9.2"
3+
version = "0.9.3"
44
description = "OCR, layout, reading order, and table recognition in 90+ languages"
55
authors = ["Vik Paruchuri <[email protected]>"]
66
readme = "README.md"

surya/common/polygon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def convert_bbox_to_polygon(cls, value):
3232
return value.tolist()
3333

3434
raise ValueError(
35-
f"Input must be either a bbox [x_min, y_min, x_max, y_max] or a polygon with 4 corners [(x,y), (x,y), (x,y), (x,y)]. You passed {value}.")
35+
f"Input must be either a bbox [x_min, y_min, x_max, y_max] or a polygon with 4 corners [(x,y), (x,y), (x,y), (x,y)]. All values must be numeric. You passed {value} of type {type(value)}. The first value is of type {type(value[0])}.")
3636

3737
@property
3838
def height(self):

surya/detection/affinity.py

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def get_detected_lines(image, slope_tol_deg=2, vertical=False, horizontal=False)
8181
bbox[1], bbox[3] = bbox[3], bbox[1]
8282
if bbox[2] < bbox[0]:
8383
bbox[0], bbox[2] = bbox[2], bbox[0]
84+
bbox = [float(b) for b in bbox]
8485
row = ColumnLine(polygon=bbox, vertical=vertical_line, horizontal=horizontal_line)
8586
line_info.append(row)
8687

surya/input/load.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def load_from_folder(folder_path, page_range: List[int] | None = None, dpi=setti
5151
for path in image_paths:
5252
extension = filetype.guess(path)
5353
if extension and extension.extension == "pdf":
54-
image, name, text_line = load_pdf(path, page_range, dpi=dpi)
54+
image, name = load_pdf(path, page_range, dpi=dpi)
5555
images.extend(image)
5656
names.extend(name)
5757
else:
5858
try:
59-
image, name, text_line = load_image(path)
59+
image, name = load_image(path)
6060
images.extend(image)
6161
names.extend(name)
6262
except PIL.UnidentifiedImageError:

surya/scripts/streamlit_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def table_recognition(img, highres_img, skip_table_detection: bool) -> (Image.Im
7676
table_imgs = [highres_img]
7777
else:
7878
_, layout_pred = layout_detection(img)
79-
layout_tables_lowres = [l.bbox for l in layout_pred.bboxes if l.label == "Table"]
79+
layout_tables_lowres = [l.bbox for l in layout_pred.bboxes if l.label in ["Table", "TableOfContents"]]
8080
table_imgs = []
8181
layout_tables = []
8282
for tb in layout_tables_lowres:

surya/scripts/table_recognition.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def table_recognition_cli(input_path: str, skip_table_detection: bool, **kwargs)
4242
table_counts.append(1)
4343
else:
4444
# The bbox for the entire table
45-
bbox = [l.bbox for l in layout_pred.bboxes if l.label == "Table"]
45+
bbox = [l.bbox for l in layout_pred.bboxes if l.label in ["Table", "TableOfContents"]]
4646
# Number of tables per page
4747
table_counts.append(len(bbox))
4848

0 commit comments

Comments
 (0)