Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy import PyMuPDF #11685

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ppocr/utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def check_and_read(img_path):
imgvalue = frame[:, :, ::-1]
return imgvalue, True, False
elif os.path.basename(img_path)[-3:].lower() == 'pdf':
import fitz
from paddle.utils import try_import
try_import('fitz')
from PIL import Image
imgs = []
with fitz.open(img_path) as pdf:
Expand Down
2 changes: 2 additions & 0 deletions ppstructure/pdf2word/pdf2word.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import platform
import numpy as np
import fitz
from paddle.utils import try_import
try_import('fitz')
from PIL import Image
from pdf2docx.converter import Converter
from qtpy.QtWidgets import QApplication, QWidget, QPushButton, QProgressBar, \
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ lxml
premailer
openpyxl
attrdict
PyMuPDF<1.21.0
Pillow>=10.0.0
pyyaml