Description
Surya 0.17.1 fails when installed with transformers>=5.0. Two separate breakages:
1. Donut encoder import error
The table recognition module imports find_pruneable_heads_and_indices from transformers.pytorch_utils, which was removed in transformers 5.x:
|
from torch import nn |
|
|
|
from transformers.activations import ACT2FN |
|
from transformers.pytorch_utils import ( |
|
find_pruneable_heads_and_indices, |
ImportError: cannot import name 'find_pruneable_heads_and_indices' from 'transformers.pytorch_utils'
2. Layout predictor config attribute error
The layout predictor accesses bbox_size on the model config, which no longer exists under transformers 5.x:
|
batch_size = settings.LAYOUT_BATCH_SIZE |
AttributeError: 'EfficientViTConfig' object has no attribute 'bbox_size'
Steps to reproduce
pip install surya-ocr==0.17.1 transformers==5.3.0
python -c "from surya.table_rec import TableRecPredictor"
Root cause
pyproject.toml specifies transformers >= "4.56.1" with no upper bound, so pip/uv will resolve to 5.x:
Workaround
Pin transformers>=4.56.1,<5 in your project dependencies.
Environment
- surya-ocr 0.17.1
- transformers 5.3.0
- Python 3.12.12
- torch 2.10.0
- Linux x86_64
Suggested fix
Either add an upper bound (transformers>=4.56.1,<5) to pyproject.toml, or update the imports/config access to use the transformers 5.x API.
Description
Surya 0.17.1 fails when installed with
transformers>=5.0. Two separate breakages:1. Donut encoder import error
The table recognition module imports
find_pruneable_heads_and_indicesfromtransformers.pytorch_utils, which was removed in transformers 5.x:surya/surya/common/donut/encoder.py
Lines 8 to 12 in e735028
2. Layout predictor config attribute error
The layout predictor accesses
bbox_sizeon the model config, which no longer exists under transformers 5.x:surya/surya/layout/__init__.py
Line 16 in e735028
Steps to reproduce
pip install surya-ocr==0.17.1 transformers==5.3.0 python -c "from surya.table_rec import TableRecPredictor"Root cause
pyproject.tomlspecifiestransformers >= "4.56.1"with no upper bound, so pip/uv will resolve to 5.x:surya/pyproject.toml
Line 28 in e735028
Workaround
Pin
transformers>=4.56.1,<5in your project dependencies.Environment
Suggested fix
Either add an upper bound (
transformers>=4.56.1,<5) topyproject.toml, or update the imports/config access to use the transformers 5.x API.