YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

PaddleOCR Inference Endpoint

A Hugging Face-compatible inference endpoint for PaddleOCR, capable of performing OCR on images in multiple languages.

Features

  • Fast and efficient OCR API using PaddleOCR
  • Support for multiple languages: Chinese, English, French, German, Korean, Japanese
  • Confidence threshold filtering
  • Optional return of annotated images with detected text regions
  • Model caching for improved performance

Files

  • app.py: Local testing application for the endpoint
  • handler.py: The main handler that processes OCR requests
  • app_gradio.py: The original Gradio-based demo application (kept for reference)
  • HF_ENDPOINT.md: Detailed documentation for using the endpoint

Supported Languages

  • Chinese (ch)
  • English (en)
  • French (fr)
  • German (german)
  • Korean (korean)
  • Japanese (japan)

Local Testing

To test the endpoint locally:

python app.py --img_path ./example_imgs/example.jpg --lang en --confidence 0.5 --return_image True

This will:

  1. Process the specified image with PaddleOCR
  2. Print the recognized text and confidence scores
  3. Save the results to test_result.json
  4. Save the annotated image to test_result.jpg (if return_image is True)

Hugging Face Deployment

See HF_ENDPOINT.md for detailed instructions on deploying and using this as a Hugging Face Inference Endpoint.

Example Usage

import requests
import base64
from PIL import Image
import io

# Load image
image = Image.open("example.jpg")
buffered = io.BytesIO()
image.save(buffered, format="JPEG")
encoded_image = base64.b64encode(buffered.getvalue()).decode('utf-8')

# API endpoint (when deployed to Hugging Face)
API_URL = "https://your-endpoint-url.huggingface.cloud"
headers = {
    "Authorization": f"Bearer {API_TOKEN}",
    "Content-Type": "application/json"
}

# Request data
data = {
    "inputs": encoded_image,
    "parameters": {
        "lang": "en",
        "confidence": 0.5,
        "return_image": False
    }
}

# Send request
response = requests.post(API_URL, headers=headers, json=data)
result = response.json()

# Process results
for item in result["result"]:
    print(f"Text: {item['text']}, Confidence: {item['score']}")

Original Demo

The original Gradio-based demo can still be run with:

python app_gradio.py

title: Paddle Ocr Demo emoji: πŸ¦€ colorFrom: indigo colorTo: gray sdk: gradio sdk_version: 5.8.0 app_file: app_gradio.py pinned: false license: mit

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support