fix: downgrade paddlepaddle to 2.6.2 for older CPU AVX compatibility
This commit is contained in:
parent
32b71cf908
commit
bb504efd02
17
extractor.py
17
extractor.py
|
|
@ -110,7 +110,19 @@ def detect_regions(page_png_path):
|
|||
from surya.layout import batch_layout_detection
|
||||
img = Image.open(page_png_path).convert("RGB")
|
||||
|
||||
layout_predictions = batch_layout_detection([img], model, processor)
|
||||
orig_w, orig_h = img.size
|
||||
scale_factor = 1.0
|
||||
# Surya has a numpy int32 overflow bug on Windows for very large images.
|
||||
# Downscale for layout detection (Surya internally downscales anyway).
|
||||
if max(orig_w, orig_h) > 2048:
|
||||
scale_factor = 2048.0 / max(orig_w, orig_h)
|
||||
new_w = int(orig_w * scale_factor)
|
||||
new_h = int(orig_h * scale_factor)
|
||||
img_for_surya = img.resize((new_w, new_h), Image.LANCZOS)
|
||||
else:
|
||||
img_for_surya = img
|
||||
|
||||
layout_predictions = batch_layout_detection([img_for_surya], model, processor)
|
||||
|
||||
regions = []
|
||||
|
||||
|
|
@ -131,7 +143,8 @@ def detect_regions(page_png_path):
|
|||
layout = layout_predictions[0]
|
||||
if hasattr(layout, 'bboxes'):
|
||||
for rid, box in enumerate(layout.bboxes, start=1):
|
||||
bbox = [int(v) for v in box.bbox]
|
||||
# Scale coordinates back up to original image dimensions
|
||||
bbox = [int(v / scale_factor) for v in box.bbox]
|
||||
raw_label = box.label
|
||||
label = label_map.get(raw_label, "text").lower()
|
||||
# Surya doesn't expose confidence in this API level easily, default to 1.0
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ PyMuPDF>=1.23
|
|||
Pillow>=10.0
|
||||
numpy>=1.24
|
||||
paddleocr==3.5.0
|
||||
paddlepaddle==3.0.0
|
||||
paddlepaddle==2.6.2
|
||||
pytesseract>=0.3.10
|
||||
anthropic>=0.40
|
||||
surya-ocr==0.4.15
|
||||
|
|
|
|||
Loading…
Reference in New Issue