ek-developers/my-ocr-api
0
๐ DeepSeek OCR API
A self-hosted OCR API powered by DeepSeek-OCR via Ollama, deployed on Hugging Face Spaces using Docker. Upload an image and receive extracted text โ with support for custom prompts.
๐ Live Demo
https://ek-developers-my-ocr-api.hf.spaceInteractive API docs available at:
https://ek-developers-my-ocr-api.hf.space/docs๐ Project Structure
โโโ Dockerfile # Container setup with Ollama + Python dependencies
โโโ start.sh # Runtime script: installs Ollama, pulls model, starts API
โโโ app.py # FastAPI application
โโโ README.md # Documentation๐ ๏ธ Tech Stack
๐ก API Reference
GET /
Health check โ confirms the API is running.
Response
{
"message": "DeepSeek OCR API running. POST an image to /ocr"
}GET /health
Lightweight health probe.
Response
{
"status": "ok"
}POST /ocr
Upload an image and extract text from it.
Request โ multipart/form-data
Example โ default prompt
curl -X POST https://ek-developers-my-ocr-api.hf.space/ocr \
-F "file=@receipt.jpg"Example โ custom prompt
curl -X POST https://ek-developers-my-ocr-api.hf.space/ocr \
-F "file=@menu.jpg" \
-F "prompt_text=Extract all menu items and prices."Response
{
"text": "Extracted text from the image..."
}Error Responses
โ๏ธ Local Development
Prerequisites
- Ollama installed locally
- Python 3.10+
Setup
# 1. Pull the model
ollama pull deepseek-ocr
# 2. Install Python dependencies
pip install fastapi uvicorn requests pydantic python-multipart
# 3. Run the API
uvicorn app:app --host 0.0.0.0 --port 7860 --reloadTest locally
curl -X POST http://localhost:7860/ocr \
-F "file=@image.jpg" \
-F "prompt_text=Free OCR."๐ณ Docker
Build and run locally
docker build -t deepseek-ocr-api .
docker run -p 7860:7860 deepseek-ocr-apiโ ๏ธ Performance Notes
This Space runs on free-tier CPU hardware (16GB RAM, no GPU).
To reduce latency, upgrade the Space hardware to a GPU instance in Settings โ Hardware.
๐ Example Use Cases
- Extract text from receipts or invoices
- Read menu items from restaurant photos
- Parse printed forms or documents
- Digitize handwritten or printed notes
๐ License
MIT License โ free to use and modify.
