DeepseekOCR / README.md
BinKhoaLe1812's picture
Upload 3 files
2020627 verified

A newer version of the Gradio SDK is available: 6.3.0

Upgrade
metadata
title: DeepSeek OCR
emoji: πŸš€
colorFrom: red
colorTo: red
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: true
short_description: DeepSeek-OCR demo on PDF and img
license: mit

API Usage

Using Gradio Client

from gradio_client import Client

client = Client("BinKhoaLe1812/DeepseekOCR")

# Process a PDF or image file
result = client.predict(
    file_path="path/to/document.pdf",  # or image file
    mode="Gundam",  # Options: Gundam, Tiny, Small, Base, Large
    task="πŸ“‹ Markdown",  # Options: πŸ“‹ Markdown, πŸ“ Free OCR, πŸ“ Locate, πŸ” Describe, ✏️ Custom
    custom_prompt="",  # Required for Custom or Locate tasks
    page_num=1,  # Page number (all pages are processed for PDFs)
    api_name="/run"
)

# Result contains: [text_out, markdown_out, raw_out, img_out, gallery]
text, markdown, raw, image, crops = result
print(text)  # Extracted text
print(markdown)  # Markdown formatted output

Using HTTP API

import requests

# Upload file and process
with open("document.pdf", "rb") as f:
    files = {"files": f}
    data = {
        "mode": "Gundam",
        "task": "πŸ“‹ Markdown",
        "custom_prompt": "",
        "page_num": 1
    }
    response = requests.post(
        "https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/api/predict",
        files=files,
        data=data
    )
    result = response.json()