{"id":20461403,"url":"https://github.com/antvis/samjs","last_synced_at":"2025-04-13T06:17:47.195Z","repository":{"id":165478396,"uuid":"640725701","full_name":"antvis/SAMJS","owner":"antvis","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-15T05:54:35.000Z","size":49657,"stargazers_count":105,"open_issues_count":10,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-13T06:17:37.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antvis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-15T01:52:45.000Z","updated_at":"2025-03-26T16:05:56.000Z","dependencies_parsed_at":"2023-06-09T07:45:26.229Z","dependency_job_id":"c8fa1531-6939-4a4c-81f7-de25c9c36ef4","html_url":"https://github.com/antvis/SAMJS","commit_stats":{"total_commits":43,"total_committers":5,"mean_commits":8.6,"dds":"0.37209302325581395","last_synced_commit":"0e4775cb5521f1ac81dea7a8f44933136f760f4c"},"previous_names":["lzxue/sam.js","antvis/sam"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2FSAMJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2FSAMJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2FSAMJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antvis%2FSAMJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antvis","download_url":"https://codeload.github.com/antvis/SAMJS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670437,"owners_count":21142905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T12:25:19.034Z","updated_at":"2025-04-13T06:17:47.167Z","avatar_url":"https://github.com/antvis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS SDK for SAM\n\nRapid development of image segmentation front-end applications inspired by [SAM DEMO](https://github.com/facebookresearch/segment-anything/tree/main/demo)\n\nthis 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.\n\n### Features\n\n- easy to use\n- JS library support Multiple Front-End Frameworks，react/vue/angular\n- worker in browser\n- support RS Image segment\n- support export vector\n- support export GeoJSON Polygon\n\n![demo](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*6rjpTIjg4cUAAAAAAAAAAAAADmJ7AQ/original)\n\n- [Document](http://samjs.antv.vision/demos)\n\n- [API](http://samjs.antv.vision/api)\n\n### Installation\n\n#### Using npm or yarn\n\nWe 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.\n\n```bash\nnpm install @antv/sam\n\n# or\n\nyarn add @antv/sam\n\n\n```\n\n### Usage\n\n#### import SAM\n\n```ts\nimport { SAM } from '@antv/sam';\n```\n\n#### 1.new a SAM instance\n\n```ts\nconst sam = new SAM({\n  modelUrl: MODEL_DIR, // the ONNX model\n});\n```\n\n#### 2. 初始化 Model，\n\n```ts\nawait sam.initModel(); // async method\n// or\nsam.initModel().then(() =\u003e {\n  // do something\n});\n```\n\n#### 3. setEmbedding\n\nget imageEmbedding from sam service.\n\n```ts\nsam.setEmbedding(imageEmbedding);\n```\n\n#### 4. set image\n\n```ts\nsam.setImage(imageUrl | HTMLImageElement); // use to clip image\n```\n\n#### 5. predict by promopts points or box\n\n```ts\nsam.predict(position); //  async method\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fsamjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantvis%2Fsamjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantvis%2Fsamjs/lists"}