Selaa lähdekoodia

Merge pull request #2451 from myhloli/dev

fix(modeling): escape backslashes in LaTeX command descriptions
Xiaomeng Zhao 6 kuukautta sitten
vanhempi
commit
c1b387abe6

+ 1 - 1
docs/README_Windows_CUDA_Acceleration_en_US.md

@@ -64,7 +64,7 @@ If your graphics card has at least 6GB of VRAM, follow these steps to test CUDA-
 1. **Overwrite the installation of torch and torchvision** supporting CUDA.(Please select the appropriate index-url based on your CUDA version. For more details, refer to the [PyTorch official website](https://pytorch.org/get-started/locally/).)
 
    ```
-   pip install --force-reinstall torch torchvision "numpy<=2.1.1" --index-url https://download.pytorch.org/whl/cu124
+   pip install --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cu124
    ```
 
 2. **Modify the value of `"device-mode"`** in the `magic-pdf.json` configuration file located in your user directory.

+ 1 - 1
docs/README_Windows_CUDA_Acceleration_zh_CN.md

@@ -65,7 +65,7 @@ pip install -U magic-pdf[full] -i https://mirrors.aliyun.com/pypi/simple
 **1.覆盖安装支持cuda的torch和torchvision**(请根据cuda版本选择合适的index-url,具体可参考[torch官网](https://pytorch.org/get-started/locally/))
 
 ```bash
-pip install --force-reinstall torch torchvision "numpy<=2.1.1" --index-url https://download.pytorch.org/whl/cu124
+pip install --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cu124
 ```
 
 **2.修改【用户目录】中配置文件magic-pdf.json中"device-mode"的值**

+ 6 - 6
magic_pdf/model/sub_modules/mfr/unimernet/unimernet_hf/modeling_unimernet.py

@@ -66,9 +66,9 @@ LEFT_RIGHT_REMOVE_PATTERN = re.compile(r'\\left\.?|\\right\.?')
 
 def fix_latex_left_right(s):
     """
-    修复LaTeX中的\left和\right命令
+    修复LaTeX中的\\left和\\right命令
     1. 确保它们后面跟有效分隔符
-    2. 平衡\left和\right的数量
+    2. 平衡\\left和\\right的数量
     """
     # 白名单分隔符
     valid_delims_list = [r'(', r')', r'[', r']', r'{', r'}', r'/', r'|',
@@ -106,7 +106,7 @@ def fix_latex_left_right(s):
 
 def fix_left_right_pairs(latex_formula):
     """
-    检测并修复LaTeX公式中\left和\right不在同一组的情况
+    检测并修复LaTeX公式中\\left和\\right不在同一组的情况
 
     Args:
         latex_formula (str): 输入的LaTeX公式
@@ -308,9 +308,9 @@ ENV_FORMAT_PATTERNS = {env: re.compile(r'\\begin\{' + env + r'\}\{([^}]*)\}') fo
 
 def fix_latex_environments(s):
     """
-    检测LaTeX中环境(如array)的\begin和\end是否匹配
-    1. 如果缺少\begin标签则在开头添加
-    2. 如果缺少\end标签则在末尾添加
+    检测LaTeX中环境(如array)的\\begin和\\end是否匹配
+    1. 如果缺少\\begin标签则在开头添加
+    2. 如果缺少\\end标签则在末尾添加
     """
     for env in ENV_TYPES:
         begin_count = len(ENV_BEGIN_PATTERNS[env].findall(s))