Skip to content

使用 SAM 实现 AI 相关 API 中的分割图片部分

ts
import { SAMPlugin } from '@infinite-canvas-tutorial/sam';

new App().addPlugins(...DefaultPlugins, UIPlugin, SAMPlugin).run();

ONNX 提供了 Web 端的运行时,这样就可以在浏览器端进行实时推理,不需要消耗任何 token。详见:How to add machine learning to your web application with ONNX Runtime

我们做了以下优化:

另外由于使用了 import.meta 这样的 ESModule 特性,因此在 tsconfig.json 中需要指定:

json
"compilerOptions": {
    "module": "ESNext"
}

Released under the MIT License.