File size: 875 Bytes
a97d040
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
import nltk
nltk.download('averaged_perceptron_tagger', download_dir='/usr/local/nltk_data')

import json
import os

file_path = "/root/magic-pdf.json"

new_config = {
    "device-mode": "cuda",
    "layout-config": {
        "model": "layoutlmv3"
    },
    "formula-config": {
        "mfd_model": "yolo_v8_mfd",
        "mfr_model": "unimernet_small",
        "enable": False
    },
    "table-config": {
        "model": "tablemaster",
        "enable": False,
        "max_time": 400
    }
}

if os.path.exists(file_path):
    with open(file_path, "r", encoding="utf-8") as file:
        try:
            data = json.load(file) 
        except json.JSONDecodeError:
            data = {}
else:
    data = {}

data.update(new_config)

with open(file_path, "w", encoding="utf-8") as file:
    json.dump(data, file, indent=4)

print(f"File '{file_path}' has been updated.")