Skip to content

Commit e8efaec

Browse files
authored
Move dependency to call method (huggingface#15941)
1 parent 5c6f57e commit e8efaec

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ def __init__(self, do_resize=True, size=224, resample=Image.BILINEAR, apply_ocr=
120120
self.resample = resample
121121
self.apply_ocr = apply_ocr
122122
self.ocr_lang = ocr_lang
123-
if apply_ocr:
124-
requires_backends(self, "pytesseract")
125123

126124
def __call__(
127125
self, images: ImageInput, return_tensors: Optional[Union[str, TensorType]] = None, **kwargs
@@ -200,6 +198,7 @@ def __call__(
200198

201199
# Tesseract OCR to get words + normalized bounding boxes
202200
if self.apply_ocr:
201+
requires_backends(self, "pytesseract")
203202
words_batch = []
204203
boxes_batch = []
205204
for image in images:

0 commit comments

Comments
 (0)