Description of the bug | 错误描述
I'm getting the 'Ran Out of Memory' error. I reinstalled and rechecked everything, but the error persists. It was running fine before, but after 2-3 inputs, I started getting this error.
How to reproduce the bug | 如何复现
magic-pdf pdf-command --pdf D:\github_p
roject\backend_code_generation\components\invoice_june.pdf --inside_model true
2024-07-21 13:52:43.517 | WARNING | magic_pdf.cli.magi
cpdf:get_model_json:312 - not found json D:\github_proj
ect\backend_code_generation\components\invoice_june.json existed
2024-07-21 13:52:43.528 | INFO | magic_pdf.cli.magi
cpdf:do_parse:92 - local output dir is D:\github_projec
t\backend_code_generation\components\output\magic-pdf\invoice_june\auto
2024-07-21 13:52:43.606 | INFO | magic_pdf.libs.pdf
_check:detect_invalid_chars:57 - cid_count: 0, text_len: 394, cid_chars_radio: 0.0
2024-07-21 13:52:52.544 | INFO | magic_pdf.model.pd
f_extract_kit:init:93 - DocAnalysis init, this may
take some times. apply_layout: True, apply_formula: True, apply_ocr: False
2024-07-21 13:52:52.545 | INFO | magic_pdf.model.pdf_extract_kit:init:101 - using device: cpu
2024-07-21 13:52:52.546 | ERROR | magic_pdf.cli.magicpdf:parse_doc:338 - Ran out of input
Traceback (most recent call last):
File "\?\D:\github_project\backend_code_generation\venv\Scripts\magic-pdf-script.py", line 33, in
sys.exit(load_entry_point('magic-pdf', 'console_scripts', 'magic-pdf')())
│ │ └ <function importlib_load_entry_point at 0x000001C518AA3E20>
│ └
└ <module 'sys' (built-in)>
File "D:\github_project\backend_code_generation\venv
lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
│ │ │ └ {}
│ │ └ ()
│ └ <function BaseCommand.main at 0x000001C519605D80>
└
File "D:\github_project\backend_code_generation\venv\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
│ │ └ <click.core.Context object at 0x000001C518C06AD0>
│ └ <function MultiCommand.invoke at 0x000001C519606D40>
└
File "D:\github_project\backend_code_generation\venv\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
│ │ │ │ └ <click.core.Context object at 0x000001C519452A70>
│ │ │ └ <function Command.invoke at 0x000001C519606830>
│ │ └
│ └ <click.core.Context object at 0x000001C519452A70>
└ <function MultiCommand.invoke.._process_result at 0x000001C530E028C0>
File "D:\github_project\backend_code_generation\venv\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
│ │ │ │ │ └ {'pdf': 'D
:\github_project\backend_code_generation\components
\invoice_june.pdf', 'inside_model': True, 'model': None, 'me...
│ │ │ │ └ <click.core.Context object at 0x000001C519452A70>
│ │ │ └ <function pdf_command at 0x000001C530E02EF0>
│ │ └
│ └ <function Context.invoke at 0x000001C5196055A0>
└ <click.core.Context object at 0x000001C519452A70>
File "D:\github_project\backend_code_generation\venv\lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
│ └ {'pdf': 'D:\github_pr
oject\backend_code_generation\components\invoice_june.pdf', 'inside_model': True, 'model': None, 'me...
└ ()
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\cli\magicpdf.py", line 352, in pdf_command
parse_doc(pdf)
│ └ 'D:\github_project\backend_code_generation\components\invoice_june.pdf'
└ <function pdf_command..parse_doc at 0x000001C530E02CB0>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\cli\magicpdf.py", line 330, in parse_doc
do_parse(
└ <function do_parse at 0x000001C530E02830>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\cli\magicpdf.py", line 112, in do_parse
pipe.pipe_analyze()
│ └ <function UNIPipe.pipe_analyze at 0x000001C530E01480>
└ <magic_pdf.pipe.UNIPipe.UNIPipe object at 0x000001C530DCBD90>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\pipe\UNIPipe.py", line 29, in pipe_analyze
self.model_list = doc_analyze(self.pdf_bytes, ocr=False)
│ │ │ │ └ b'%PDF-1.4\n1
0 obj\n<<\n/Title (\xfe\xff\x00D\x00o\x00c\x00u\x00m\x0
0e\x00n\x00t)\n/Creator (\xfe\xff\x00w\x00k\x00h\x00t\x0...
│ │ │ └ <magic_pdf.pipe.UNIPipe.UNIPipe object at 0x000001C530DCBD90>
│ │ └ <function doc_analyze at 0x000001C5251CE4D0>
│ └ []
└ <magic_pdf.pipe.UNIPipe.UNIPipe object at 0x000001C530DCBD90>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\model\doc_analyze_by_custom_model.py", line 101, in doc_analyze
custom_model = model_manager.get_model(ocr, show_log)
│ │ │ └ False
│ │ └ False
│ └ <function ModelSingleton.get_model at 0x000001C5251CE440>
└ <magic_pdf.model.doc_analyze_by_custom_model.ModelSingleton object at 0x000001C530E10460>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\model\doc_analyze_by_custom_model.py", line 63, in get_model
self._models[key] = custom_model_init(ocr=ocr, show_log=show_log)
│ │ │ │ │ └ False
│ │ │ │ └ False
│ │ │ └ <function custom_model_init at 0x000001C5251CE320>
│ │ └ (False, False)
│ └ {}
└ <magic_pdf.model.doc_analyze_by_custom_model.ModelSingleton object at 0x000001C530E10460>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\model\doc_analyze_by_custom_model.py", line 85, in custom_model_init
custom_model = CustomPEKModel(ocr=ocr, show_log=show_log, models_dir=local_models_dir, device=device)
│ │ │ │ └ 'cpu'
│ │ │
└ 'D:\github_project\backend_code_generation\components\PDF-Extract-Kit\models'
│ │ └ False
│ └ False
└ <class 'magic_pdf.model.pdf_extract_kit.CustomPEKModel'>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\model\pdf_extract_kit.py", line 107, in init
self.mfd_model = mfd_model_init(str(os.path.join(models_dir, self.configs["weights"]["mfd"])))
│ │ │ │ │ │
│ └ {'config': {'device': 'cpu', 'layout':
True, 'formula': True}, 'weights': {'layout': 'Layout/model_final.pth', 'mfd': 'MFD/we...
│ │ │ │ │ │
└ <magic_pdf.model.pdf_extract_kit.CustomPEKModel object at 0x000001C530E103D0>
│ │ │ │ │ └
'D:\github_project\backend_code_generation\components\PDF-Extract-Kit\models'
│ │ │ │ └ <function join at 0x000001C518BB72E0>
│ │ │ └ <module 'n
tpath' from 'C:\Users\mishr\AppData\Local\Programs\Python\Python310\lib\ntpath.py'>
│ │ └ <module 'os'
from 'C:\Users\mishr\AppData\Local\Programs\Python\Python310\lib\os.py'>
│ └ <function mfd_model_init at 0x000001C530E03910>
└ <magic_pdf.model.pdf_extract_kit.CustomPEKModel object at 0x000001C530E103D0>
File "d:\github_project\backend_code_generation\compo
nents\mineru\magic_pdf\model\pdf_extract_kit.py", line 30, in mfd_model_init
mfd_model = YOLO(weight)
│ └ 'D:\github_project\backend_cod
e_generation\components\PDF-Extract-Kit\models\MFD/weights.pt'
└ <class 'ultralytics.models.yolo.model.YOLO'>
File "D:\github_project\backend_code_generation\venv
lib\site-packages\ultralytics\models\yolo\model.py", line 23, in init
super().init(model=model, task=task, verbose=verbose)
│ │ └ False
│ └ None
└ 'D:\github_project\backe
nd_code_generation\components\PDF-Extract-Kit\models\MFD/weights.pt'
File "D:\github_project\backend_code_generation\venv
lib\site-packages\ultralytics\engine\model.py", line 149, in init
self._load(model, task=task)
│ │ │ └ None
│ │ └ 'D:\github_project\backend_code_gene
ration\components\PDF-Extract-Kit\models\MFD/weights.pt'
│ └ <function Model._load at 0x000001C543CE23B0>
└ YOLO()
File "D:\github_project\backend_code_generation\venv
lib\site-packages\ultralytics\engine\model.py", line 230, in _load
self.model, self.ckpt = attempt_load_one_weight(weights)
│ │ │ │ │ └ '
D:\github_project\backend_code_generation\components\PDF-Extract-Kit\models\MFD/weights.pt'
│ │ │ │ └ <function attempt_load_one_weight at 0x000001C543C5D000>
│ │ │ └ None
│ │ └ YOLO()
│ └ None
└ YOLO()
File "D:\github_project\backend_code_generation\venv
lib\site-packages\ultralytics\nn\tasks.py", line 855, in attempt_load_one_weight
ckpt, weight = torch_safe_load(weight) # load ckpt
│ └ 'D:\github_projec
t\backend_code_generation\components\PDF-Extract-Kit\models\MFD/weights.pt'
└ <function torch_safe_load at 0x000001C543C5CEE0>
File "D:\github_project\backend_code_generation\venv
lib\site-packages\ultralytics\nn\tasks.py", line 781, in torch_safe_load
ckpt = torch.load(file, map_location="cpu")
│ │ └ 'D:\github_project\backend_co
de_generation\components\PDF-Extract-Kit\models\MFD\weights.pt'
│ └ <function load at 0x000001C534921240>
└ <module 'torch' from 'D:\github_project\
backend_code_generation\venv\lib\site-packages\torch\init.py'>
File "D:\github_project\backend_code_generation\venv
lib\site-packages\torch\serialization.py", line 1040, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
│ │ │ │ └ {'encoding': 'utf-8'}
│ │ │ └ <m
odule 'pickle' from 'C:\Users\mishr\AppData\Local\Programs\Python\Python310\lib\pickle.py'>
│ │ └ 'cpu'
│ └ <_io.BufferedReader name='D:
\github_project\backend_code_generation\components\PDF-Extract-Kit\models\MFD\weights.pt'>
└ <function _legacy_load at 0x000001C5349213F0>
File "D:\github_project\backend_code_generation\venv
lib\site-packages\torch\serialization.py", line 1262, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
│ │ │ └ {'encoding': 'utf-8'}
│ │ └ <_io.BufferedRe
ader name='D:\github_project\backend_code_generation\components\PDF-Extract-Kit\models\MFD\weights.pt'>
│ └
└ <module 'pickle' from 'C:\Users\
mishr\AppData\Local\Programs\Python\Python310\lib\pickle.py'>
EOFError: Ran out of input
This is present in my magic-pdf.json file -
{
"bucket_info":{
"bucket-name-1":["ak", "sk", "endpoint"],
"bucket-name-2":["ak", "sk", "endpoint"]
},
"temp-output-dir":"D:\github_project\backend_code_generation\components\output",
"models-dir": "D:\github_project\backend_code_generation\components\PDF-Extract-Kit\models",
"device-mode":"cpu"
}
Operating system | 操作系统
Windows
Python version | Python 版本
3.10
Software version | 软件版本 (magic-pdf --version)
0.6.x
Device mode | 设备模式
cpu