Image-Text-to-Text
Transformers
Safetensors
English
qwen2_vl
Math
OCR
Latex
VLM
Plain_Text
KIE
Equations
VQA
conversational
text-generation-inference
Instructions to use prithivMLmods/Qwen2-VL-OCR-2B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Qwen2-VL-OCR-2B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/Qwen2-VL-OCR-2B-Instruct") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("prithivMLmods/Qwen2-VL-OCR-2B-Instruct") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/Qwen2-VL-OCR-2B-Instruct", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use prithivMLmods/Qwen2-VL-OCR-2B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/Qwen2-VL-OCR-2B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/Qwen2-VL-OCR-2B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/prithivMLmods/Qwen2-VL-OCR-2B-Instruct
- SGLang
How to use prithivMLmods/Qwen2-VL-OCR-2B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "prithivMLmods/Qwen2-VL-OCR-2B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/Qwen2-VL-OCR-2B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "prithivMLmods/Qwen2-VL-OCR-2B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/Qwen2-VL-OCR-2B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use prithivMLmods/Qwen2-VL-OCR-2B-Instruct with Docker Model Runner:
docker model run hf.co/prithivMLmods/Qwen2-VL-OCR-2B-Instruct
Update README.md
Browse files
README.md
CHANGED
|
@@ -15,12 +15,17 @@ tags:
|
|
| 15 |
- Latex
|
| 16 |
- VLM
|
| 17 |
- Plain_Text
|
|
|
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
-
# Qwen2-VL-OCR-2B-Instruct [ VL / OCR ]
|
| 20 |
|
| 21 |

|
| 22 |
|
| 23 |
-
The **Qwen2-VL-OCR-2B-Instruct** model is a fine-tuned version of **Qwen/Qwen2-VL-2B-Instruct**, tailored for tasks that involve **Optical Character Recognition (OCR)**, **image-to-text conversion**, and **math problem solving with LaTeX formatting**. This model integrates a conversational approach with visual and textual understanding to handle multi-modal tasks effectively.
|
|
|
|
|
|
|
| 24 |
|
| 25 |
#### Key Enhancements:
|
| 26 |
|
|
@@ -32,6 +37,11 @@ The **Qwen2-VL-OCR-2B-Instruct** model is a fine-tuned version of **Qwen/Qwen2-V
|
|
| 32 |
|
| 33 |
* **Multilingual Support**: to serve global users, besides English and Chinese, Qwen2-VL now supports the understanding of texts in different languages inside images, including most European languages, Japanese, Korean, Arabic, Vietnamese, etc.
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
| **File Name** | **Size** | **Description** | **Upload Status** |
|
| 36 |
|---------------------------|------------|------------------------------------------------|-------------------|
|
| 37 |
| `.gitattributes` | 1.52 kB | Configures LFS tracking for specific model files. | Initial commit |
|
|
@@ -46,11 +56,7 @@ The **Qwen2-VL-OCR-2B-Instruct** model is a fine-tuned version of **Qwen/Qwen2-V
|
|
| 46 |
| `vocab.json` | 2.78 MB | Vocabulary file for tokenization. | Uploaded |
|
| 47 |
|
| 48 |
---
|
| 49 |
-
### Sample Inference with Doc
|
| 50 |
-
|
| 51 |
-

|
| 52 |
|
| 53 |
-
**📍Demo**: https://huggingface.co/prithivMLmods/Qwen2-VL-OCR-2B-Instruct/blob/main/Demo/ocrtest_qwen.ipynb
|
| 54 |
### How to Use
|
| 55 |
|
| 56 |
```python
|
|
|
|
| 15 |
- Latex
|
| 16 |
- VLM
|
| 17 |
- Plain_Text
|
| 18 |
+
- KIE
|
| 19 |
+
- Equations
|
| 20 |
+
- VQA
|
| 21 |
---
|
| 22 |
+
# **Qwen2-VL-OCR-2B-Instruct [ VL / OCR ]**
|
| 23 |
|
| 24 |

|
| 25 |
|
| 26 |
+
> The **Qwen2-VL-OCR-2B-Instruct** model is a fine-tuned version of **Qwen/Qwen2-VL-2B-Instruct**, tailored for tasks that involve **Optical Character Recognition (OCR)**, **image-to-text conversion**, and **math problem solving with LaTeX formatting**. This model integrates a conversational approach with visual and textual understanding to handle multi-modal tasks effectively.
|
| 27 |
+
|
| 28 |
+
[](https://huggingface.co/prithivMLmods/Qwen2-VL-OCR-2B-Instruct/blob/main/Demo/ocrtest_qwen.ipynb)
|
| 29 |
|
| 30 |
#### Key Enhancements:
|
| 31 |
|
|
|
|
| 37 |
|
| 38 |
* **Multilingual Support**: to serve global users, besides English and Chinese, Qwen2-VL now supports the understanding of texts in different languages inside images, including most European languages, Japanese, Korean, Arabic, Vietnamese, etc.
|
| 39 |
|
| 40 |
+
|
| 41 |
+
### Sample Inference
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
|
| 45 |
| **File Name** | **Size** | **Description** | **Upload Status** |
|
| 46 |
|---------------------------|------------|------------------------------------------------|-------------------|
|
| 47 |
| `.gitattributes` | 1.52 kB | Configures LFS tracking for specific model files. | Initial commit |
|
|
|
|
| 56 |
| `vocab.json` | 2.78 MB | Vocabulary file for tokenization. | Uploaded |
|
| 57 |
|
| 58 |
---
|
|
|
|
|
|
|
|
|
|
| 59 |
|
|
|
|
| 60 |
### How to Use
|
| 61 |
|
| 62 |
```python
|