Views
No views yet
1curl -X POST https://huggingface.co/spaces/YOUR_USERNAME/deepseek-ocr/api/predict \
2 -H "Content-Type: application/json" \
3 -d '{
4 "image": "base64_encoded_image",
5 "prompt": "Free OCR."
6 }'1import requests
2import base64
3from PIL import Image
4import io
5
6# Load image
7img = Image.open('image.jpg')
8img_bytes = io.BytesIO()
9img.save(img_bytes, format='JPEG')
10img_b64 = base64.b64encode(img_bytes.getvalue()).decode()
11
12# Make request
13response = requests.post(
14 'https://huggingface.co/spaces/YOUR_USERNAME/deepseek-ocr/api/predict',
15 json={'image': img_b64, 'prompt': 'Free OCR.'}
16)
17
18result = response.json()
19print(result['text'])1async function extractText(imageFile) {
2 const reader = new FileReader();
3 reader.onload = async (e) => {
4 const base64 = e.target.result.split(',')[1];
5
6 const response = await fetch(
7 'https://huggingface.co/spaces/YOUR_USERNAME/deepseek-ocr/api/predict',
8 {
9 method: 'POST',
10 headers: { 'Content-Type': 'application/json' },
11 body: JSON.stringify({
12 image: base64,
13 prompt: 'Free OCR.'
14 })
15 }
16 );
17
18 const result = await response.json();
19 console.log(result.text);
20 };
21 reader.readAsDataURL(imageFile);
22}| Setting | Speed | Quality | GPU Memory |
|---|---|---|---|
| Tiny (512) | Very Fast | Low | ~4GB |
| Small (640) | Fast | Medium | ~6GB |
| Base (1024) | Normal | High | ~10GB |
| Large (1280) | Slow | Very High | ~14GB |
1# Clone this space
2git clone https://huggingface.co/spaces/YOUR_USERNAME/deepseek-ocr
3
4# Install dependencies
5pip install -r requirements.txt
6
7# Fine-tune on your data
8python finetune.py --data your_ocr_dataset.json
9
10# Push back
11git push1{
2 "text": "extracted_text_here",
3 "status": "success",
4 "model": "DeepSeek-OCR",
5 "device": "cuda:0",
6 "error": null
7}1@article{deepseek2024ocr,
2 title={DeepSeek-OCR: Deep Learning for Optical Character Recognition},
3 author={DeepSeek Team},
4 year={2024}
5}