Skip to content

Use SAM to implement AI API

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

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

ONNX provides a web-based runtime, enabling real-time inference directly in the browser without consuming any tokens. For details, see: How to add machine learning to your web application with ONNX Runtime

We have implemented the following optimizations:

Since we use import.meta to import worker code, which is a feature of ESModule, so we need to use the following config in tsconfig.json:

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

Released under the MIT License.