JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q45352F
  • License MIT

TensorflowJS text detection implementation (inference), mainly based on ctpn model in tensorflow, id card detect, connectionist text proposal network

Package Exports

  • tfjs-text-detection-ctpn

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tfjs-text-detection-ctpn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tfjs-text-detection-ctpn

TensorflowJS text detection implementation (inference), mainly based on ctpn model in tensorflow, id card detect, connectionist text proposal network The origin paper can be found here. Also, the origin repo in caffe can be found in here. If you got any questions, check the issue first, if the problem persists, open a new issue.

Check out this project right in your browser!

Demo.

Setup

npm i tfjs-text-detection-ctpn

Config object, that have to be passed to constructor:

   {
     NMS_FUNCTION: 'AUTH' | 'TF', specifies which non maximum suppression function we gonna use. TF faster, AUTH more accurate
     ANCHOR_SCALES: [16],
     PIXEL_MEANS: tf.tensor([[[102.9801, 115.9465, 122.7717]]]),
     SCALES: [600,] , // model input layer preferable size
     MAX_SIZE:  1000, 
     HAS_RPN: true,
     DETECT_MODE: 'O' | 'H', // 'O' - Oriented mode (boxes will be rotated by angle), now supports only oriented one ( H - horisontal)
     pre_nms_topN: 12000,
     post_nms_topN: 2000,
     nms_thresh:0.7, // threshold for nms function
     min_size: 8,
   }

Example

import * as tf from '@tensorflow/tfjs-node-gpu';
import CTPN from 'tfjs-text-detection-ctpn';

(async ()=> {
    const cfg = {
        NMS_FUNCTION: 'AUTH',
        ANCHOR_SCALES: [16],
        PIXEL_MEANS: tf.tensor([[[102.9801, 115.9465, 122.7717]]]),
        SCALES: [600,] ,
        MAX_SIZE:  1000,
        HAS_RPN: true,
        DETECT_MODE: 'O',
        pre_nms_topN: 12000,
        post_nms_topN: 2000,
        nms_thresh:0.7,
        min_size: 8,
    };
    const ctpn = new CTPN(cfg);
    const image = './test/007.jpg';
    const predicted = await ctpn.predict(image);
    console.log(predicted);
    ctpn.draw(image,'res.jpg',...predicted, 'black')
})();

Some results