Update README.md
Browse files
README.md
CHANGED
|
@@ -56,6 +56,8 @@ MinerU2.5: A Decoupled Vision-Language Model for Efficient High-Resolution Docum
|
|
| 56 |
# Quick Start
|
| 57 |
For convenience, we provide `mineru-vl-utils`, a Python package that simplifies the process of sending requests and handling responses from MinerU2.5 Vision-Language Model. Here we give some examples to use MinerU2.5. For more information and usages, please refer to [mineru-vl-utils](https://github.com/opendatalab/mineru-vl-utils/tree/main).
|
| 58 |
|
|
|
|
|
|
|
| 59 |
## Install packages
|
| 60 |
```bash
|
| 61 |
# For `transformers` backend
|
|
@@ -94,7 +96,7 @@ extracted_blocks = client.two_step_extract(image)
|
|
| 94 |
print(extracted_blocks)
|
| 95 |
```
|
| 96 |
|
| 97 |
-
## `vllm-engine` Example
|
| 98 |
|
| 99 |
```python
|
| 100 |
from vllm import LLM
|
|
@@ -117,6 +119,44 @@ extracted_blocks = client.two_step_extract(image)
|
|
| 117 |
print(extracted_blocks)
|
| 118 |
```
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
# Model Architecture
|
| 121 |
<p align="center">
|
| 122 |
<img alt="Image" src="https://hotelll.github.io/MinerU2.5/Mineru25_framework.jpeg"/>
|
|
|
|
| 56 |
# Quick Start
|
| 57 |
For convenience, we provide `mineru-vl-utils`, a Python package that simplifies the process of sending requests and handling responses from MinerU2.5 Vision-Language Model. Here we give some examples to use MinerU2.5. For more information and usages, please refer to [mineru-vl-utils](https://github.com/opendatalab/mineru-vl-utils/tree/main).
|
| 58 |
|
| 59 |
+
📌 We strongly recommend using vllm for inference, as the `vllm-async-engine` can achieve a concurrent inference speed of **2.12 fps** on one A100.
|
| 60 |
+
|
| 61 |
## Install packages
|
| 62 |
```bash
|
| 63 |
# For `transformers` backend
|
|
|
|
| 96 |
print(extracted_blocks)
|
| 97 |
```
|
| 98 |
|
| 99 |
+
## `vllm-engine` Example (Recommended!)
|
| 100 |
|
| 101 |
```python
|
| 102 |
from vllm import LLM
|
|
|
|
| 119 |
print(extracted_blocks)
|
| 120 |
```
|
| 121 |
|
| 122 |
+
## `vllm-async-engine` Example (Recommended!)
|
| 123 |
+
|
| 124 |
+
```python
|
| 125 |
+
import io
|
| 126 |
+
import asyncio
|
| 127 |
+
import aiofiles
|
| 128 |
+
|
| 129 |
+
from vllm.v1.engine.async_llm import AsyncLLM
|
| 130 |
+
from vllm.engine.arg_utils import AsyncEngineArgs
|
| 131 |
+
from PIL import Image
|
| 132 |
+
from mineru_vl_utils import MinerUClient
|
| 133 |
+
from mineru_vl_utils import MinerULogitsProcessor # if vllm>=0.10.1
|
| 134 |
+
|
| 135 |
+
async_llm = AsyncLLM.from_engine_args(
|
| 136 |
+
AsyncEngineArgs(
|
| 137 |
+
model="opendatalab/MinerU2.5-2509-1.2B",
|
| 138 |
+
logits_processors=[MinerULogitsProcessor] # if vllm>=0.10.1
|
| 139 |
+
)
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
client = MinerUClient(
|
| 143 |
+
backend="vllm-async-engine",
|
| 144 |
+
vllm_async_llm=async_llm,
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
async def main():
|
| 148 |
+
image_path = "/path/to/the/test/image.png"
|
| 149 |
+
async with aiofiles.open(image_path, "rb") as f:
|
| 150 |
+
image_data = await f.read()
|
| 151 |
+
image = Image.open(io.BytesIO(image_data))
|
| 152 |
+
extracted_blocks = await client.aio_two_step_extract(image)
|
| 153 |
+
print(extracted_blocks)
|
| 154 |
+
|
| 155 |
+
asyncio.run(main())
|
| 156 |
+
|
| 157 |
+
async_llm.shutdown()
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
# Model Architecture
|
| 161 |
<p align="center">
|
| 162 |
<img alt="Image" src="https://hotelll.github.io/MinerU2.5/Mineru25_framework.jpeg"/>
|