1.0.1 • Published 2 years ago

@paddlejs-mediapipe/data-processor-simplify v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

English

@paddlejs-mediapipe/data-processor

A npm package which provide APIs about dataProcessing in Paddle.js.

npm

npm install @paddlejs-mediapipe/data-processor

Usage

import { genFeedData, nj } from '@paddlejs-mediapipe/data-processor';

const options = {
    targetShape: [1, 3, 224, 224], // required
    mean: [0.5, 0.5, 0.5],
    std: [1, 1, 1],
    colorType: 0, // 0: rgb; 1: bgr; default 0
    normalizeType: 0, // data normalize type: 0: 0~1; 1:-1~1; default 0
    isNchw: true // the format of output, default false
};

// Array data that the length should match the targetShape in options.
const data = Array.from(new Array(3 * 224 * 224), () => 244);
const feedData = genFeedData(data, options);

// use numjs
const numData = nj.array([1, 2, 3, 4], 'float32');
const reshapedData = nj.reshape(numData, [2, 2]);
const transposedData = nj.transpose(1, 0);
const flattenedData = transposedData.flatten();