← Back to Skills Marketplace
xx235300

BaiduOCR-LocalFallback

by xx235300 · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ⚠ suspicious
96
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install baiduocr-localfallback
Description
Provides 115+ Baidu OCR APIs with automatic EasyOCR local fallback, image preprocessing, token caching, and auto-retry for stable text recognition.
README (SKILL.md)

BaiduOCR-LocalFallback

Disclaimer:

  1. This project is not an official Baidu product and has no affiliation with Baidu. This project only provides a wrapper for Baidu OCR API; users must apply for a Baidu Cloud account and comply with Baidu's terms of service.
  2. This project is 99% AI-generated. The AI's owner has no programming background. Please evaluate the project's feasibility before use.

115+ Baidu OCR API interfaces with EasyOCR local fallback — auto-switches to local recognition when the network is unstable.

Features

  • 115+ OCR APIs - General, ID cards, receipts, documents, education, and more
  • Local fallback - Integrates EasyOCR; auto-switches when Baidu OCR is unavailable
  • Image preprocessing - Auto compresses and converts to fit the 4MB limit
  • Token caching - access_token cached for 25 days
  • Auto retry - Retries 3 times on network fluctuations
  • Multiple config methods - Environment variables, config file, or interactive setup

Installation

One-click install

bash \x3C(curl -s https://raw.githubusercontent.com/xx235300/BaiduOCR-LocalFallback/main/install.sh)

Manual install

# 1. Clone the repo
git clone https://github.com/xx235300/BaiduOCR-LocalFallback.git
cd BaiduOCR-LocalFallback

# 2. Install dependencies
pip3 install -r requirements.txt

# 3. Configure API credentials
python3 scripts/ocr.py --configure

Quick Start

from scripts.ocr import OCR

ocr = OCR()

# General text recognition
result = ocr.recognize(image="/path/to/image.jpg", api="general_basic")

# ID card recognition
result = ocr.recognize(image="/path/to/idcard.jpg", api="idcard", id_card_side="front")

# Handwriting (local fallback)
result = ocr.recognize(image="/path/to/handwriting.jpg", api="handwriting")

Supported APIs

General Text

API Description
general General text (with location)
general_basic General text (basic)
accurate High-accuracy (with location)
accurate_basic High-accuracy (basic)

ID & Cards

API Description
idcard ID card
bankcard Bank card
passport Passport
business_license Business license

Receipts

API Description
receipt General receipt
vat_invoice VAT invoice
taxi_receipt Taxi receipt
train_ticket Train ticket
invoice Invoice

Handwriting / Documents

API Description
handwriting Handwriting recognition
table Table recognition
formula Formula recognition

More APIs (115+)

Run python3 scripts/ocr.py --show-apis for the full list.

Configuration

Method 1: Interactive

python3 scripts/ocr.py --configure

Method 2: Environment variables (recommended for security)

export BAIDU_OCR_API_KEY="\x3Cyour_api_key>"
export BAIDU_OCR_SECRET_KEY="\x3Cyour_secret_key>"

Method 3: Config file

mkdir -p ~/.openclaw/skills/BaiduOCR-LocalFallback
cat > ~/.openclaw/skills/BaiduOCR-LocalFallback/config.json \x3C\x3C 'EOF'
{
  "api_key": "\x3Cyour_api_key>",
  "secret_key": "\x3Cyour_secret_key>"
}
EOF
chmod 600 ~/.openclaw/skills/BaiduOCR-LocalFallback/config.json

Response Format

{
  "words_result": [
    {"words": "Recognized text", "location": {"vertices": [{"x": 0, "y": 0}, ...]}}
  ],
  "words_result_num": 1,
  "fallback_info": {  // only present when using local fallback
    "engine": "EasyOCR",
    "message": "Baidu OCR unavailable, using local EasyOCR"
  }
}

Error Handling

from scripts.ocr import OCR
from scripts.baidu_client import BaiduOCRError

ocr = OCR()
try:
    result = ocr.recognize(image="/path/to/image.jpg")
except BaiduOCRError as e:
    print(f"Baidu OCR error: {e.error_code} - {e.error_msg}")
except Exception as e:
    print(f"Other error: {e}")

FAQ

Q: I have no coding experience, what should I do if an error occurs during use?

Just send the cloud document link to the AI and let it troubleshoot and find a solution on its own. Sample prompt:

Please troubleshoot and resolve the issue according to the skill usage documentation.
Skill Usage Documentation: https://my.feishu.cn/docx/Gjy0djSado5YqVxzO6ecYbOmn4g?from=from_copylink

Q: How to get Baidu OCR API credentials?

  1. Go to Baidu Cloud Console
  2. Search "OCR" or "文字识别"
  3. Create an app and enable the OCR services you need
  4. Get API Key and Secret Key from "My Apps"

Q: "Baidu OCR call failed" but no auto-switch to local fallback?

Check if fallback is disabled:

ocr = OCR(use_fallback=False)  # Fallback disabled

Q: EasyOCR initialization is slow?

First run requires downloading models (~100MB). Pre-initialize:

from scripts.local_ocr import local_ocr
local_ocr._init_reader()  # Warm up

Q: How to handle Base64 images?

import base64

# Read image and convert to Base64
with open("image.jpg", "rb") as f:
    img_base64 = base64.b64encode(f.read()).decode()

result = ocr.recognize(image=img_base64, api="general_basic")

Q: How to specify output format?

# Table - returns Excel
result = ocr.recognize(image="table.jpg", api="table", request_type="excel")

# Table - returns JSON
result = ocr.recognize(image="table.jpg", api="table", request_type="json")

Q: Web image recognition failed?

Web images must be publicly accessible. Ensure:

  1. Image URL is publicly reachable
  2. Firewall allows outbound 80/443
  3. Try downloading locally first

Q: How to disable SSL certificate verification (dev only)?

import os
os.environ['REQUESTS_CA_BUNDLE'] = '/path/to/ca-bundle.crt'

Performance Tips

  • First-time EasyOCR requires downloading models (~100MB), please be patient
  • Recommended image size under 2MB for best performance
  • Large images are auto-compressed and scaled
  • access_token is auto-cached and refreshed

Related Documents

Baidu Cloud Documentation Center

License

MIT © 2026 xx235300

Usage Guidance
Before installing: 1) Note the metadata mismatch — the registry claims no credentials but the skill requires Baidu API Key and Secret (package.json and SKILL.md do require them). 2) Review the repository content (especially scripts/ocr.py and any network calls) before running the one‑click install; piping a remote script into bash (curl | bash) is convenient but risky. 3) Prefer using environment variables over storing keys in ~/.openclaw/.../config.json; if you store the file, keep permissions restrictive (chmod 600) and consider using a dedicated service account with minimal privileges. 4) Understand privacy: images (and their text) may be sent to Baidu's servers; avoid sending highly sensitive images. 5) Expect EasyOCR to download ~100MB of model data and pip to install dependencies. If you are uncomfortable with remote execution or storing secrets in a file, inspect and run the install script manually or run the project in an isolated environment (container or VM).
Capability Assessment
Purpose & Capability
The skill's declared purpose (Baidu OCR + EasyOCR fallback) matches the code and documentation: it needs Baidu API Key/Secret and installs EasyOCR. However, the registry metadata at the top of the report said 'Required env vars: none' and 'Primary credential: none', while package.json and SKILL.md/package scripts clearly require/configure Baidu api_key and secret_key. This metadata mismatch is an incoherence that should be resolved before trusting the skill.
Instruction Scope
SKILL.md and install.sh limit actions to installing Python deps, creating a per-skill config directory under ~/.openclaw, prompting for/storing Baidu keys, and testing the Baidu token endpoint. The instructions do not ask the agent to read unrelated system files or exfiltrate arbitrary data. They do, however, provide examples that will send image data (including Base64) to Baidu's endpoints — which is expected but a privacy risk for sensitive images.
Install Mechanism
No formal install spec in the registry, but SKILL.md documents a one‑click install that fetches an install.sh from raw.githubusercontent.com and pipes it to bash. raw.githubusercontent.com is a common host, but piping remote scripts into a shell is higher risk than a manual review/install. The included install.sh itself uses pip to install mainstream Python packages (requests, easyocr, Pillow) and writes config files under the user's home — behavior consistent with the stated purpose but still requires trusting the remote script or inspecting it first.
Credentials
The skill legitimately requires Baidu API Key and Secret for remote OCR; these are requested in SKILL.md, configured in ~/.openclaw/skills/BaiduOCR-LocalFallback/config.json, and declared as required in package.json.openclaw.config. However, the registry metadata claimed no required env vars/credentials — a direct inconsistency. No unrelated credentials are requested, and the script advises chmod 600 for stored credentials, but storing secrets in a file is still sensitive and the skill offers environment variable configuration (recommended).
Persistence & Privilege
The skill does not request 'always: true' or system-wide changes. Its installation writes files under the invoking user's home (~/.openclaw/skills/BaiduOCR-LocalFallback) and installs Python packages into the environment — typical for a user-level tool. It does not attempt to alter other skills' configs or escalate privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install baiduocr-localfallback
  3. After installation, invoke the skill by name or use /baiduocr-localfallback
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.1.0
- Added an extra disclaimer stating the project is 99% AI-generated and advising users to evaluate feasibility. - Clarified/configuration instructions: recommend environment variables for security, added file permissions step for config file. - Minor updates for clarity on token caching descriptions. - No code or functionality changes; documentation only.
v1.0.0
- Initial release of BaiduOCR-LocalFallback. - Integrates 115+ Baidu OCR API interfaces with automatic EasyOCR local fallback. - Automatically switches to local recognition when Baidu OCR service is unavailable or the network is unstable. - Includes image preprocessing, token caching for 25 days, and auto-retry on network issues. - Offers multiple configuration methods: environment variables, config file, or interactive prompt. - Provides sample code, error handling, and FAQ for quick setup and troubleshooting.
Metadata
Slug baiduocr-localfallback
Version 1.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is BaiduOCR-LocalFallback?

Provides 115+ Baidu OCR APIs with automatic EasyOCR local fallback, image preprocessing, token caching, and auto-retry for stable text recognition. It is an AI Agent Skill for Claude Code / OpenClaw, with 96 downloads so far.

How do I install BaiduOCR-LocalFallback?

Run "/install baiduocr-localfallback" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is BaiduOCR-LocalFallback free?

Yes, BaiduOCR-LocalFallback is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does BaiduOCR-LocalFallback support?

BaiduOCR-LocalFallback is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created BaiduOCR-LocalFallback?

It is built and maintained by xx235300 (@xx235300); the current version is v1.1.0.

💬 Comments