File size: 1,785 Bytes
5a410c3 1c89141 5a410c3 1c89141 5a410c3 1c89141 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | ---
title: DeepSeek OCR 2 API
emoji: 🔍
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
license: apache-2.0
app_port: 7860
---
# DeepSeek-OCR-2 API
REST API لاستخراج النص من الصور باستخدام نموذج [DeepSeek-OCR-2](https://huggingface.co/deepseek-ai/DeepSeek-OCR-2).
## Endpoints
| Method | Path | Description |
|--------|------|-------------|
| GET | `/` | معلومات الـ API |
| GET | `/health` | فحص حالة النموذج |
| POST | `/ocr` | OCR عبر رفع ملف |
| POST | `/ocr/base64` | OCR عبر base64 JSON |
## POST /ocr — Form Data
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `image` | file | ✅ | صورة JPG/PNG/WEBP |
| `x` | int | ❌ | بداية المحور الأفقي للـ crop (بكسل) |
| `y` | int | ❌ | بداية المحور الرأسي للـ crop (بكسل) |
| `w` | int | ❌ | عرض منطقة الـ crop (بكسل) |
| `h` | int | ❌ | ارتفاع منطقة الـ crop (بكسل) |
| `mode` | string | ❌ | `free` (افتراضي) أو `markdown` |
### مثال — cURL
```bash
# OCR كاملة للصورة
curl -X POST "https://YOUR-SPACE.hf.space/ocr" \
-F "image=@pedigree.jpg" \
-F "mode=free"
# OCR على منطقة محددة (bounding box)
curl -X POST "https://YOUR-SPACE.hf.space/ocr" \
-F "image=@pedigree.jpg" \
-F "x=100" -F "y=50" -F "w=300" -F "h=150" \
-F "mode=free"
```
### Response
```json
{
"text": "النص المستخرج من الصورة",
"mode": "free",
"cropped": true,
"bbox": { "x": 100, "y": 50, "w": 300, "h": 150 }
}
```
## POST /ocr/base64 — JSON Body
```json
{
"image_b64": "<base64 string>",
"x": 100,
"y": 50,
"w": 300,
"h": 150,
"mode": "free"
}
``` |