# Paddle.js Paddle.js是百度Paddle的web方向子项目,是一个运行在浏览器中的开源深度学习框架。Paddle.js可以加载提前训练好的paddle模型,或者将paddle hub中的模型通过paddle.js的模型转换工具变成浏览器友好的模型进行在线推理预测使用。目前,paddle.js仅可以在支持webGL的浏览器中运行。 ## 主要特点 ### Modular Web project is built on Atom system which is a versatile framework to support GPGPU operation on WebGL. It is quite modular and could be used to make computation tasks faster by utilizing WebGL. ### 浏览器覆盖范围 * PC: Chrome(windows, mac, ubuntu) * Android: Baidu App, chrome and QQ Browser * safari: Baidu App and safari ### 支持的操作 Currently Paddle.js only supports a limited set of Paddle Ops. See the full list. If your model uses unsupported ops, the Paddle.js script will fail and produce a list of the unsupported ops in your model. Please file issues to let us know what ops you need support with. 目前,Paddle.js只支持有限的一组算子操作。如果您的模型使用不支持的操作,那么padde.js将运行失败,如果您的模型中存在不支持的op操作的列表。请提出问题,让我们知道你需要支持。 [查看完整列表](./src/factory/fshader/README.md) ## 加载和运行模型 如果原始模型是浏览器友好的model格式, 使用 paddle.load()接在模型。 ```bash import {runner as Paddlejs} from 'paddlejs'; const paddlejs = new Paddlejs({ modelPath: 'model/mobilenetv2', // model path fileCount: 4, // model data file count feedShape: { // input shape fw: 256, fh: 256 }, fetchShape: [1, 1, 1920, 10], // output shape fill: '#fff', // fill color when resize image needBatch: true, // whether need to complete the shape to 4 dimension inputType: 'image' // whether is image or video }); // load paddlejs model and preheat await paddlejs.loadModel(); // run model await paddlejs.predict(img, postProcess); function postProcee(data) { // data is predicted result console.log(data); } ```