Skip to content

Commit b46d5ce

Browse files
Merge pull request #259 from VikParuchuri/dev
Bugfixes and `pdftext` improvements
2 parents 0ce57a2 + a3fde2f commit b46d5ce

File tree

6 files changed

+590
-757
lines changed

6 files changed

+590
-757
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,15 @@ Setting the `LAYOUT_BATCH_SIZE` env var properly will make a big difference when
230230
from PIL import Image
231231
from surya.detection import batch_text_detection
232232
from surya.layout import batch_layout_detection
233-
from surya.model.layout.model import load_model, load_processor
233+
from surya.model.detection.model import load_model as load_det_model, load_processor as load_det_processor
234+
from surya.model.layout.model import load_model as load_layout_model
235+
from surya.model.layout.processor import load_processor as load_layout_processor
234236

235237
image = Image.open(IMAGE_PATH)
236-
model = load_model()
237-
processor = load_processor()
238-
det_model = load_model()
239-
det_processor = load_processor()
238+
model = load_layout_model()
239+
processor = load_layout_processor()
240+
det_model = load_det_model()
241+
det_processor = load_det_processor()
240242

241243
# layout_predictions is a list of dicts, one per image
242244
line_predictions = batch_text_detection([image], det_model, det_processor)

ocr_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,22 @@ def page_count(pdf_file):
204204
if text_det:
205205
det_img, pred = text_detection(pil_image)
206206
with col1:
207-
st.image(det_img, caption="Detected Text", use_column_width=True)
207+
st.image(det_img, caption="Detected Text", use_container_width=True)
208208
st.json(pred.model_dump(exclude=["heatmap", "affinity_map"]), expanded=True)
209209

210210

211211
# Run layout
212212
if layout_det:
213213
layout_img, pred = layout_detection(pil_image)
214214
with col1:
215-
st.image(layout_img, caption="Detected Layout", use_column_width=True)
215+
st.image(layout_img, caption="Detected Layout", use_container_width=True)
216216
st.json(pred.model_dump(exclude=["segmentation_map"]), expanded=True)
217217

218218
# Run OCR
219219
if text_rec:
220220
rec_img, pred = ocr(pil_image, pil_image_highres, languages)
221221
with col1:
222-
st.image(rec_img, caption="OCR Result", use_column_width=True)
222+
st.image(rec_img, caption="OCR Result", use_container_width=True)
223223
json_tab, text_tab = st.tabs(["JSON", "Text Lines (for debugging)"])
224224
with json_tab:
225225
st.json(pred.model_dump(), expanded=True)
@@ -230,8 +230,8 @@ def page_count(pdf_file):
230230
if table_rec:
231231
table_img, pred = table_recognition(pil_image, pil_image_highres, in_file, page_number - 1 if page_number else None, use_pdf_boxes, skip_table_detection)
232232
with col1:
233-
st.image(table_img, caption="Table Recognition", use_column_width=True)
233+
st.image(table_img, caption="Table Recognition", use_container_width=True)
234234
st.json([p.model_dump() for p in pred], expanded=True)
235235

236236
with col2:
237-
st.image(pil_image, caption="Uploaded Image", use_column_width=True)
237+
st.image(pil_image, caption="Uploaded Image", use_container_width=True)

0 commit comments

Comments
 (0)