Unverified Commit e8efaecb authored by NielsRogge's avatar NielsRogge Committed by GitHub
Browse files

Move dependency to call method (#15941)

parent 5c6f57ee
......@@ -120,8 +120,6 @@ class LayoutLMv2FeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionM
self.resample = resample
self.apply_ocr = apply_ocr
self.ocr_lang = ocr_lang
if apply_ocr:
requires_backends(self, "pytesseract")
def __call__(
self, images: ImageInput, return_tensors: Optional[Union[str, TensorType]] = None, **kwargs
......@@ -200,6 +198,7 @@ class LayoutLMv2FeatureExtractor(FeatureExtractionMixin, ImageFeatureExtractionM
# Tesseract OCR to get words + normalized bounding boxes
if self.apply_ocr:
requires_backends(self, "pytesseract")
words_batch = []
boxes_batch = []
for image in images:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment