npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

paddleocr-js

v0.1.0

Published

JavaScript wrapper for PaddleOCR, providing OCR capabilities in browser and Node.js

Readme

PaddleOCR-JS

JavaScript wrapper for PaddleOCR, providing OCR capabilities in browser and Node.js

安装

# npm
npm install paddleocr-js

# yarn
yarn add paddleocr-js

# pnpm
pnpm add paddleocr-js

基本用法

浏览器环境

<script src="dist/browser/index.min.js"></script>
<script>
  const paddleOCR = new PaddleOCR({
    modelPath: 'path/to/models',
    useTensorflow: true,
    useWasm: true
  });
  
  // 启动OCR
  paddleOCR.init().then(() => {
    // 对图像进行处理
    paddleOCR.recognize(imageElement).then(result => {
      console.log(result);
    });
  });
</script>

Node.js环境

const { PaddleOCR } = require('paddleocr-js');
const fs = require('fs');

async function runOCR() {
  // 创建PaddleOCR实例
  const paddleOCR = new PaddleOCR({
    modelPath: 'path/to/models',
    useTensorflow: true
  });
  
  // 初始化
  await paddleOCR.init();
  
  // 读取图像并识别
  const imageBuffer = fs.readFileSync('path/to/image.jpg');
  const result = await paddleOCR.recognize(imageBuffer);
  
  console.log(result);
}

runOCR();

使用ES模块

import { PaddleOCR } from 'paddleocr-js';

async function detectText() {
  const paddleOCR = new PaddleOCR({
    modelPath: 'path/to/models',
    useTensorflow: true,
    useWasm: true
  });
  
  await paddleOCR.init();
  
  const result = await paddleOCR.recognize(imageElement);
  return result;
}

配置选项

const options = {
  // 模型路径
  modelPath: 'path/to/models',
  
  // 后端选择
  useTensorflow: true, // 使用TensorFlow.js作为后端
  useONNX: false,      // 使用ONNX Runtime作为后端
  
  // 特定环境优化
  useWasm: true,       // 在浏览器中使用WASM加速
  enableGPU: false,    // 在Node.js中启用GPU加速
  
  // 模型选择
  detectionModel: 'DB', // 文字检测模型
  recognitionModel: 'CRNN', // 文字识别模型
  
  // 语言设置
  language: 'ch',      // 支持语言: 'ch', 'en', 'japan', 'korean' 等
  
  // 功能开关
  enableDetection: true,     // 启用文本检测
  enableRecognition: true,   // 启用文本识别
  enableLayout: false,       // 启用版面分析
  enableTable: false,        // 启用表格识别
  
  // 性能设置
  maxWorkers: 4,             // WebWorker最大数量
  maxConcurrency: 4,         // 最大并发任务数
  
  // 回调函数
  onProgress: (progress, stage) => {
    console.log(`进度: ${progress}%, 阶段: ${stage}`);
  }
};

const paddleOCR = new PaddleOCR(options);

API文档

详细API文档请参见API文档

浏览器兼容性

  • Chrome 83+
  • Firefox 79+
  • Safari 15.4+
  • Edge 83+

Node.js兼容性

  • Node.js 14.x 及以上版本

许可证

Apache 2.0

贡献指南

如果您想为项目做出贡献,请参阅贡献指南

相关项目

  • PaddleOCR - 高效的OCR工具库
  • TensorFlow.js - 用于在浏览器和Node.js中训练和部署ML模型的JavaScript库