Spaces:
Runtime error
Runtime error
Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Typhoon OCR
|
| 2 |
+
|
| 3 |
+
Typhoon OCR is a model for extracting structured markdown from images or PDFs. It supports document layout analysis and table extraction, returning results in markdown or HTML. This package is a simple Gradio website to demonstrate the performance of Typhoon OCR.
|
| 4 |
+
|
| 5 |
+
### Features
|
| 6 |
+
|
| 7 |
+
- Upload a PDF or image (single page)
|
| 8 |
+
- Extracts and reconstructs document content as markdown
|
| 9 |
+
- Supports different prompt modes for layout or structure
|
| 10 |
+
- Language: English, Thai
|
| 11 |
+
- Uses a local or remote OpenAI-compatible API (e.g., vllm, opentyphoon.ai)
|
| 12 |
+
- See blog for more detail https://opentyphoon.ai/blog/en/typhoon-ocr-release
|
| 13 |
+
|
| 14 |
+
### Requirements
|
| 15 |
+
|
| 16 |
+
- Linux / Mac with python (window not supported at the moment)
|
| 17 |
+
|
| 18 |
+
### Install
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
pip install typhoon-ocr
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
or to run the gradio app.
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
pip install -r requirements.txt
|
| 28 |
+
# edit .env
|
| 29 |
+
# pip install vllm # optional for hosting a local server
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
### Mac specific
|
| 33 |
+
|
| 34 |
+
```
|
| 35 |
+
brew install poppler
|
| 36 |
+
# The following binaries are required and provided by poppler:
|
| 37 |
+
# - pdfinfo
|
| 38 |
+
# - pdftoppm
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
### Linux specific
|
| 42 |
+
|
| 43 |
+
```
|
| 44 |
+
sudo apt-get update
|
| 45 |
+
sudo apt-get install poppler-utils
|
| 46 |
+
# The following binaries are required and provided by poppler-utils:
|
| 47 |
+
# - pdfinfo
|
| 48 |
+
# - pdftoppm
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Start vllm
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
vllm serve scb10x/typhoon-ocr-7b --served-model-name typhoon-ocr --dtype bfloat16 --port 8101
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
### Run Gradio demo
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
python app.py
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### Dependencies
|
| 64 |
+
|
| 65 |
+
- openai
|
| 66 |
+
- python-dotenv
|
| 67 |
+
- ftfy
|
| 68 |
+
- pypdf
|
| 69 |
+
- gradio
|
| 70 |
+
- vllm (for hosting an inference server)
|
| 71 |
+
- pillow
|
| 72 |
+
|
| 73 |
+
### Debug
|
| 74 |
+
|
| 75 |
+
- If `Error processing document` occur. Make sure you have install `brew install poppler` or `apt-get install poppler-utils`.
|
| 76 |
+
|
| 77 |
+
### License
|
| 78 |
+
|
| 79 |
+
This project is licensed under the Apache 2.0 License. See individual datasets and checkpoints for their respective licenses.
|