Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
63a4a062
Commit
63a4a062
authored
Jun 25, 2024
by
赵小蒙
Browse files
update demo model json and code
parent
7dcf63e6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
39021 deletions
+24
-39021
demo/demo.py
demo/demo.py
+22
-0
demo/demo1.json
demo/demo1.json
+1
-24521
demo/demo2.json
demo/demo2.json
+1
-14500
No files found.
demo/demo.py
0 → 100644
View file @
63a4a062
import
os
import
json
from
magic_pdf.pipe.UNIPipe
import
UNIPipe
from
magic_pdf.rw.DiskReaderWriter
import
DiskReaderWriter
current_script_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
demo_name
=
"demo1"
pdf_path
=
os
.
path
.
join
(
current_script_dir
,
f
"
{
demo_name
}
.pdf"
)
model_path
=
os
.
path
.
join
(
current_script_dir
,
f
"
{
demo_name
}
.json"
)
pdf_bytes
=
open
(
pdf_path
,
"rb"
).
read
()
model_json
=
json
.
loads
(
open
(
model_path
,
"r"
,
encoding
=
"utf-8"
).
read
())
jso_useful_key
=
{
"_pdf_type"
:
""
,
"model_list"
:
model_json
}
local_image_dir
=
os
.
path
.
join
(
current_script_dir
,
'images'
)
image_dir
=
str
(
os
.
path
.
basename
(
local_image_dir
))
image_writer
=
DiskReaderWriter
(
local_image_dir
)
pipe
=
UNIPipe
(
pdf_bytes
,
jso_useful_key
,
image_writer
)
pipe
.
pipe_classify
()
pipe
.
pipe_parse
()
md_content
=
pipe
.
pipe_mk_markdown
(
image_dir
,
drop_mode
=
"none"
)
with
open
(
f
"
{
demo_name
}
.md"
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
md_content
)
demo/demo1.json
View file @
63a4a062
This diff is collapsed.
Click to expand it.
demo/demo2.json
View file @
63a4a062
This diff is collapsed.
Click to expand it.
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