Skip to content

fly2yu/SAMJS

 
 

Repository files navigation

SAM JS SDK for SAM

demo

Installation

Using npm or yarn

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

Usage

import SAM

import { SAM } from '@antv/sam';

1.new a SAM instance

const sam = new SAM({
  modelUrl: MODEL_DIR, // the ONNX model
});

2. 初始化 Model,

await sam.initModel(); // async method
// or
sam.initModel().then(() => {
  // do something
});

3. setEmbedding

get imageEmbedding from sam service.

sam.setEmbedding(imageEmbedding);

4. set image

sam.setImage(imageUrl | HTMLImageElement); // use to clip image

5. predict by promopts points or box

sam.predict(position); //  async method

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.8%
  • JavaScript 6.7%
  • Shell 0.5%