Model
weights: Mirror Site, Original Site
Original GitHub: GOT-OCR2.0
This project was developed under Windows, so I can't guarantee that it will work on Linux. If you want to use it on
Linux, you can check this issue
I used GLM4 and Deepseek to generate some of my codes.
Click a star, please
- Support for
llama-cpp-python
, hoping to accelerate inference - I ran into some troubles, if you have the solution, you can create a pull request, pull into
Alpha
branch for now; HuggingFace model used is kaifeise/GOT-gguf;GGUF Test.py
used codes from 1694439208/GOT-OCR-Inference. Files are in thegguf
folder - html to word functionality, preserve formulas for editing
- I got two ideas for now. One is creating docx from PDF files, but it's too slow since you need selenium to open your
browser and output PDFs. The other is
pdflatex
, but you have to have latex installed. I checked TexLive, but it's too big, so I'm not sure if it's worth it. Is anyone interested in this?
If you don't have the folder mentioned here, create a new one
This environment was tested under python 3.11.9.
Choose a suitable GPU version of torch
and from PyTorch and install
it.
I am using stable 2.4.1 + cu124, so I suggest you to use this version.
Not a must-have, but if you want to install it, check #12
I have tested that if you install it directly through requiremtns.txt
, then you will get
ModuleNotFoundError: No module named 'frontend'
error. But if you install it separately in commandline, it will work
fine. I don't know the reason why, just try it yourself.
By the way, if you still get the ModuleNotFoundError
, try to uninstall and reinstall fitz
and PyMuPDF
separately.
I have tested that pip install -U
won't work. Strange.
pip install fitz
pip install PyMuPDF
pip install -r requirements.txt
And, someone said that he encountered conflicting dependencies after installing. But I didn't find any conflicting
dependencies in the requirements.txt
file, and pipdeptree
shows that nothing is conflicting. I used pip freeze
to
create this requirements.txt
file, so it should be fine.
However, this problem really happened, so I provided a requirements-noversion.txt
that doesn't contain version
numbers.
For more information, see this issue #4
pip install -r requirements-noversion.txt
- Edge WebDriver,
download the
.zip
file, unzip it and put it intomsedgedriver
folder
This requires the Edge browser to be installed on your computer, which is preinstalled on Windows.
The file structure should be:GOT-OCR-2-GUI └─edge_driver ├─msedgedriver.exe └─...
- Download to
models
folder - Stop downloading fewer files
- The file structure should be:
GOT-OCR-2-GUI
└─models
├─config.json
├─generation_config.json
├─got_vision_b.py
├─model.safetensors
├─modeling_GOT.py
├─qwen.tiktoken
├─render_tools.py
├─special_tokens_map.json
├─tokenization_qwen.py
└─tokenizer_config.json
- If you want to use the command line, then use
CLI.py
. - If you want to use the graphical interface, then use
GUI.py
. - If you want to modify settings, then use
Config Manager.py
. - If you want to perform automated rendering operations, then use
Renderer.py
, which will automatically render all.jpg
and.png
images in theimgs
folder.
Those using the GUI can ignore this, but for those using the CLI, remember to place the images you want to OCR into the
imgs
folder (the CLI currently only detects.jpg
and.png
files).
- You can find various language
.json
files in theLocales
folder, with CLI and GUI language files stored separately. - In the
gui
subfolder, in addition to thelanguage.json
file, there is also aninstructions
folder that contains the built-in tutorials for the GUI, named aslanguage.md
. - To modify language support, simply change the value of
'language'
in theconfig.json
file. The available options correspond to the file names without extensions in thelanguage.json
files. - If you wish to add language support, for the CLI, just add a new
language.json
file (I strongly recommend using an existing file as a starting point). For the GUI, you will also need the correspondinglanguage.md
file. - You can run
Config Manager.py
to manage the language and other configuration files.
Error Code | Message |
---|---|
1 | Config file not found |
2 | Language file not found |
3 | CLI do not have support for folder |
4 | Input file not found |
5 | Unsupported file type |
6 | Failed to detect encoding of rendered HTMLs |
- DO NOT DELETE
markdown-it.js
insideresult
folder, or pdf outputting may fail
If you deleted it, you can find a backup in
scripts
folder. Just copy it toresult
folder.
- If the script crashes, you can try running
cmd
withpython + file name
, I encountered crashes during testing, but I don't know why - Make sure hat you installed the gpu version of
torch
-
Q: CLI.py: error: the following arguments are required: --path/-P
-
A: Use PowerShell instead, cmd has this problem and I can't find the reason.
-
Q: What is an "HTML local file"? Are there HTML files that are not saved locally?
-
A: Although the HTML files output by the model are saved locally, they use external scripts. Therefore, even if the file is on your local machine, you still need an internet connection to open it. I have downloaded the external script, which is the previously mentioned
markdown-it.js
. The main reason for doing this is to prevent PDF export failures due to network issues. -
Q: Why did my model fail to load?
-
A: Check if you are missing any files. It seems that the model files downloaded from Baidu Cloud are missing some files. I recommend you download from the previously mentioned Huggingface instead.
-
Q:Any suggestions on deploying this repo?
-
A: See this issue #5
-
Q: Where can I read the document?
-
A: For GUI users, you can navigate to
instruction
tab. For CLI users, you can run.\CLI.py --help
to read documents automatically generated by argparse, or run.\CLI.py --detailed-help
to read a more detailed version.