banner
lca

lca

真正的不自由,是在自己的心中设下牢笼。

windows上安装marker

wallhaven-7pxqe9

项目地址:https://github.com/VikParuchuri/marker

官方介绍说,Marker 将 PDF、EPUB 和 MOBI 转换为 markdown 文档,且比 nougat 快 10 倍。

官方只提供 linux 和 mac 的安装方式,参考在 windows 上安装成功。

下面是安装步骤:

1、安装 Visual Studio 2022
2、安装 NVIDIA CUDA
3、安装 PyTorch

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

4、安装 wheel

pip install wheel

5、安装 detectron2,需要本地安装,报错参考:#issuecomment-651560907

步骤如下:

git clone https://github.com/facebookresearch/detectron2.git
cd detectron2/

#管理员权限运行cmd
python setup.py install

修改detectron2\layers\csrc\nms_rotated\nms_rotated_cuda.cu文件的内容为下述内容

// Copyright (c) Facebook, Inc. and its affiliates.
#include <ATen/ATen.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <ATen/cuda/CUDAApplyUtils.cuh>
/*#ifdef WITH_CUDA
#include "../box_iou_rotated/box_iou_rotated_utils.h"
#endif
// TODO avoid this when pytorch supports "same directory" hipification
#ifdef WITH_HIP
#include "box_iou_rotated/box_iou_rotated_utils.h"
#endif*/
#include "box_iou_rotated/box_iou_rotated_utils.h"

修改后运行如下命令即可

python setup.py install

6、继续安装 Windows 版本的 Tesseract 和 Ghostscript

Tesseract:

tesseract-ocr-w64-setup-5.3.3.20231005.exe

Ghostscript:

gs10021w64.exe

7、安装 VikParuchuri/marker

git clone https://github.com/VikParuchuri/marker.git

从 VikParuchuri/marker/requirements.txt 中删除 detectron2,并使用上述步骤手动安装它(也就是第五步,如果安装了这里可以跳过,所以就移除 detectron2 依赖)

安装其他没装的依赖

pip install -r requirements.txt
pip install ftfy
pip install spellchecker
pip install pyspellchecker
pip install ocrmypdf
pip install nltk
pip install thefuzz
pip uninstall python-magic
pip install python-magic-bin
pip install ray==2.7.1

8、安装 nougat

#下述方法会报错
pip install nougat-ocr

#通过这种方式安装
pip install git+https://github.com/facebookresearch/nougat

运行python convert_single.py "Vim 101 Hacks.pdf" vim.md --parallel_factor 5报错:

1、报错如下:

python convert_single.py "Vim 101 Hacks.pdf" vim.md --parallel_factor 5
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
C:\Users\lca\AppData\Roaming\Python\Python311\site-packages\torch\functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ..\aten\src\ATen\native\TensorShape.cpp:3527.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

处理此报错信息:

找到这个文件C:\Users\lca\AppData\Roaming\Python\Python311\site-packages\torch\functional.py,修改return _VF.meshgrid(tensors, **kwargs)return _VF.meshgrid(tensors, **kwargs, indexing = 'ij')。即可。

参考:marker
参考:issues

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.