Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
53ccd5a6
Commit
53ccd5a6
authored
Jun 28, 2024
by
赵小蒙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add try import opencv-python and Pillow
parent
17be5497
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
doc_analyze_by_custom_model.py
magic_pdf/model/doc_analyze_by_custom_model.py
+5
-3
No files found.
magic_pdf/model/doc_analyze_by_custom_model.py
View file @
53ccd5a6
import
fitz
import
cv2
from
PIL
import
Image
import
numpy
as
np
from
loguru
import
logger
from
magic_pdf.model.model_list
import
MODEL
import
magic_pdf.model
as
model_config
...
...
@@ -23,6 +20,11 @@ def remove_duplicates_dicts(lst):
def
load_images_from_pdf
(
pdf_bytes
:
bytes
,
dpi
=
200
)
->
list
:
try
:
import
cv2
from
PIL
import
Image
except
ImportError
:
logger
.
error
(
"opencv-python and Pillow are not installed, please install by pip."
)
images
=
[]
with
fitz
.
open
(
"pdf"
,
pdf_bytes
)
as
doc
:
for
index
in
range
(
0
,
doc
.
page_count
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment