@antv/sam
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

JS SDK for SAM

Rapid development of image segmentation front-end applications inspired by SAM DEMO

this enhanced front-end library provides a seamless solution for loading fixed image or geoImages and their corresponding .npy file embeddings. It empowers you to run the SAM ONNX model in the browser using Web Assembly, while leveraging multi-threading capabilities, SharedArrayBuffer, Web Worker, and SIMD128 to achieve optimal performance.

Features

  • easy to use
  • JS library support Multiple Front-End Frameworks,react/vue/angular
  • worker in browser
  • support RS Image segment
  • support export vector
  • support export GeoJSON Polygon

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

Readme

Keywords

none

Package Sidebar

Install

npm i @antv/sam

Weekly Downloads

20

Version

0.2.0

License

MIT

Unpacked Size

93.3 kB

Total Files

22

Last publish

Collaborators

  • xuying1027
  • lvisei
  • yisi.wang
  • basketduck
  • biupiubiupiu
  • flash1
  • dreammy23
  • laixingui.lxg
  • zhangjunjie-loki
  • rainy25ghz
  • zeyuwang
  • yanxiong
  • susiwen8
  • freestyle21
  • soundquiet
  • elaine.q.10
  • sturuby
  • sakuya223
  • serializedowen
  • xdzhao
  • yangzhanmei
  • wjgogogo
  • leungwensen
  • dori
  • iaaron
  • yard
  • simaq
  • dxq613
  • intchous
  • susan_ann
  • jinke.li
  • lzxue
  • army8735
  • atool
  • baizn
  • dengfuping
  • neoddish
  • jeffy2012
  • zqlu
  • afc163
  • pomelo-nwu
  • kopiluwaky
  • ccnuzindex
  • panyuqi
  • bubkoo
  • zengyue
  • kasmine
  • boyu.zlj
  • l1ud0ngq1
  • newbyvector
  • winniexing
  • chenluli
  • kn9117
  • xdddst
  • semious2020
  • esora
  • nadia_liu
  • bbsqq
  • mxz96102
  • openwayne
  • pearmini
  • pddpd
  • yiqianyao
  • zhanba
  • cxxxxxn