|
|
--- |
|
|
language: |
|
|
- en |
|
|
- zh |
|
|
tags: |
|
|
- vision |
|
|
- ocr |
|
|
- deepseek |
|
|
- quantization |
|
|
- int4 |
|
|
license: other |
|
|
base_model: deepseek-ai/DeepSeek-OCR |
|
|
--- |
|
|
|
|
|
# DeepSeek-OCR INT4 Merged Model |
|
|
|
|
|
This is a merged version of the DeepSeek-OCR model that was quantized to INT4 and then dequantized back to full precision. |
|
|
|
|
|
## Model Details |
|
|
|
|
|
- **Base Model**: [deepseek-ai/DeepSeek-OCR](https://huggingface.co/deepseek-ai/DeepSeek-OCR) |
|
|
- **Quantization**: INT4 (during storage) |
|
|
- **Final Format**: Full precision (FP32/FP16) |
|
|
- **Source**: Quantized weights from SamMikaelson/deepseekocr-randomreal |
|
|
|
|
|
## Usage |
|
|
|
|
|
```python |
|
|
from transformers import AutoModelForCausalLM, AutoProcessor |
|
|
from PIL import Image |
|
|
|
|
|
# Load model and processor |
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
|
"YOUR_USERNAME/OCR-int4-merged", |
|
|
trust_remote_code=True |
|
|
) |
|
|
processor = AutoProcessor.from_pretrained( |
|
|
"YOUR_USERNAME/OCR-int4-merged", |
|
|
trust_remote_code=True |
|
|
) |
|
|
|
|
|
# Process image |
|
|
image = Image.open("document.jpg") |
|
|
inputs = processor(images=image, return_tensors="pt") |
|
|
|
|
|
# Generate OCR output |
|
|
outputs = model.generate(**inputs, max_new_tokens=512) |
|
|
text = processor.decode(outputs[0], skip_special_tokens=True) |
|
|
print(text) |
|
|
``` |
|
|
|
|
|
## Notes |
|
|
|
|
|
This model was created by: |
|
|
1. Quantizing the original DeepSeek-OCR to INT4 |
|
|
2. Dequantizing back to full precision |
|
|
3. Merging into a standard model format |
|
|
|
|
|
The process allows for efficient storage and distribution while maintaining full model capabilities. |
|
|
|