We recommend using npm or yarn to install, it not only makes development easier, but also allow you to take advantage of the rich ecosystem of Javascript packages and tooling.
npm install @antv/sam
# or
yarn add @antv/sam
import { SAM } from '@antv/sam';
const sam = new SAM({
modelUrl: MODEL_DIR, // the ONNX model
});
await sam.initModel(); // async method
// or
sam.initModel().then(() => {
// do something
});
get imageEmbedding from sam service.
sam.setEmbedding(imageEmbedding);
sam.setImage(imageUrl | HTMLImageElement); // use to clip image
sam.predict(position); // async method