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
ea8f7e0f
Unverified
Commit
ea8f7e0f
authored
Jan 13, 2025
by
Xiaomeng Zhao
Committed by
GitHub
Jan 13, 2025
Browse files
Merge pull request #1521 from opendatalab/dev
fix: fix import path
parents
bfebcef6
fae67894
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
projects/multi_gpu/server.py
projects/multi_gpu/server.py
+8
-4
projects/web_demo/web_demo/api/analysis/pdf_ext.py
projects/web_demo/web_demo/api/analysis/pdf_ext.py
+1
-1
No files found.
projects/multi_gpu/server.py
View file @
ea8f7e0f
...
...
@@ -10,8 +10,6 @@ import filetype
import
litserve
as
ls
from
pathlib
import
Path
from
fastapi
import
HTTPException
from
magic_pdf.tools.cli
import
do_parse
,
convert_file_to_pdf
from
magic_pdf.model.doc_analyze_by_custom_model
import
ModelSingleton
class
MinerUAPI
(
ls
.
LitAPI
):
...
...
@@ -24,6 +22,12 @@ class MinerUAPI(ls.LitAPI):
if
torch
.
cuda
.
device_count
()
>
1
:
raise
RuntimeError
(
"Remove any CUDA actions before setting 'CUDA_VISIBLE_DEVICES'."
)
from
magic_pdf.tools.cli
import
do_parse
,
convert_file_to_pdf
from
magic_pdf.model.doc_analyze_by_custom_model
import
ModelSingleton
self
.
do_parse
=
do_parse
self
.
convert_file_to_pdf
=
convert_file_to_pdf
model_manager
=
ModelSingleton
()
model_manager
.
get_model
(
True
,
False
)
model_manager
.
get_model
(
False
,
False
)
...
...
@@ -41,7 +45,7 @@ class MinerUAPI(ls.LitAPI):
try
:
pdf_name
=
str
(
uuid
.
uuid4
())
output_dir
=
self
.
output_dir
.
joinpath
(
pdf_name
)
do_parse
(
self
.
output_dir
,
pdf_name
,
inputs
[
0
],
[],
**
inputs
[
1
])
self
.
do_parse
(
self
.
output_dir
,
pdf_name
,
inputs
[
0
],
[],
**
inputs
[
1
])
return
output_dir
except
Exception
as
e
:
shutil
.
rmtree
(
output_dir
,
ignore_errors
=
True
)
...
...
@@ -73,7 +77,7 @@ class MinerUAPI(ls.LitAPI):
return
f
.
convert_to_pdf
()
else
:
temp_file
.
write_bytes
(
file_bytes
)
convert_file_to_pdf
(
temp_file
,
temp_dir
)
self
.
convert_file_to_pdf
(
temp_file
,
temp_dir
)
return
temp_file
.
with_suffix
(
'.pdf'
).
read_bytes
()
else
:
raise
Exception
(
'Unsupported file format'
)
...
...
projects/web_demo/web_demo/api/analysis/pdf_ext.py
View file @
ea8f7e0f
...
...
@@ -16,7 +16,7 @@ from magic_pdf.data.data_reader_writer import FileBasedDataWriter
from
magic_pdf.data.dataset
import
PymuDocDataset
from
magic_pdf.libs.json_compressor
import
JsonCompressor
from
magic_pdf.model.doc_analyze_by_custom_model
import
doc_analyze
from
magic_pdf.
model.
operators
import
InferenceResult
from
magic_pdf.operators
.models
import
InferenceResult
from
..extentions
import
app
,
db
from
.ext
import
find_file
...
...
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