File size: 1,644 Bytes
26f2ae1
 
e4f2c8b
9792a79
ad3d21e
e4f2c8b
 
7d52d8f
 
 
4a324fd
6afe5a9
 
d1a9d53
e5b238e
688ccfc
fd6a04e
7d52d8f
 
 
 
 
 
 
 
 
 
 
 
 
92d8f68
7d52d8f
 
 
 
fd6a04e
 
3a68729
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) Opendatalab. All rights reserved.

import os
import json
from loguru import logger


if __name__ == '__main__':
    os.system('pip uninstall -y mineru')
    os.system('pip install git+https://github.com/myhloli/Magic-PDF.git@dev')
    os.system('pip install -U mineru-vl-utils')
    os.system('mineru-models-download -s huggingface -m all')
    # os.system('mineru-models-download -s modelscope -m all')
    os.environ['MINERU_MODEL_SOURCE'] = "local"
    os.environ['GRADIO_SSR_MODE'] = "false"
    os.environ['MINERU_PDF_RENDER_TIMEOUT'] = "10"
    try:
        with open('/home/user/mineru.json', 'r+') as file:
            config = json.load(file)
            
            delimiters = {
                'display': {'left': '\\[', 'right': '\\]'},
                'inline': {'left': '\\(', 'right': '\\)'}
            }
            
            config['latex-delimiter-config'] = delimiters
            
            if os.getenv('apikey'):
                config['llm-aided-config']['title_aided']['api_key'] = os.getenv('apikey')
                config['llm-aided-config']['title_aided']['enable'] = True
                config['llm-aided-config']['title_aided']['model'] = "qwen3-next-80b-a3b-instruct"
            
            file.seek(0)  # 将文件指针移回文件开始位置
            file.truncate()  # 截断文件,清除原有内容
            json.dump(config, file, indent=4)  # 写入新内容
    except Exception as e:
        logger.exception(e)
    os.system('mineru-gradio --enable-vllm-engine true --enable-api false --max-convert-pages 20 --latex-delimiters-type b --gpu-memory-utilization 0.5')