npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cornerstonejs/ai

v4.20.0

Published

AI and ML Interfaces for Cornerstone3D

Downloads

18,084

Readme

Cornerstone AI Client Package

This package provides AI interfaces for use with Cornerstone in client-side applications. It is designed to support the use of ONNX models, ensuring a clean separation between server-side AI processing and client-specific functionalities tied to Cornerstone.

Key Features

  • ONNX Runtime Web Integration: The package leverages the ONNX Runtime Web library, enabling AI models to run directly in the browser without relying on server-side execution.
  • Initial Model - Segment Anything Model (SAM): Our first supported model is the Segment Anything Model (SAM) https://segment-anything.com/, designed for segmentation tasks.

Getting Started

WASM Files

The ONNX Runtime Web requires WASM files to run in the browser. These files need to be copied to your application's public directory. The files should be placed in an /ort/ directory in your public folder.

In Webpack you can add the WASM files to the public folder like this:

new CopyPlugin({
  patterns: [
    {
      from: '../../../node_modules/onnxruntime-web/dist',
      to: '${destPath.replace(/\\/g, '/')}/ort',
    },
  ],
}),

This will copy all the necessary WASM files from the ONNX Runtime Web package to your application's public directory. Make sure your build system is configured to handle WASM files and that the asyncWebAssembly experiment is enabled in your build configuration.

Running the Example

To see the package in action with the Segment Anything Model, use the following command:

yarn run example segmentAnythingClientSide

This will load the SAM model in the browser and allow you to perform segmentation tasks on images.

Model Files

The package does not include model binaries due to their size and to give users the flexibility to use their own models. You can download pre-trained model binaries from the following links:

Base model (vit_b) - 178 MB compressed

  • https://ohif-assets-new.s3.us-east-1.amazonaws.com/SAM/sam_b.zip

Large model (vit_l) - 1.16 GB compressed

  • https://ohif-assets-new.s3.us-east-1.amazonaws.com/SAM/sam_l.zip

Huge model (vit_h) - 2.38 GB compressed

  • https://ohif-assets-new.s3.us-east-1.amazonaws.com/SAM/sam_h.zip

For the examples we are using the model url and fetch it from the web. If you see in example code we have:

URL to the model files

const models = {
  sam_b: [
    {
      name: 'sam-b-encoder',
      url: 'https://huggingface.co/schmuell/sam-b-fp16/resolve/main/sam_vit_b_01ec64.encoder-fp16.onnx',
      size: 180,
      key: 'encoder',
    },
    {
      name: 'sam-b-decoder',
      url: 'https://huggingface.co/schmuell/sam-b-fp16/resolve/main/sam_vit_b_01ec64.decoder.onnx',
      size: 17,
      key: 'decoder',
    },
  ],
};

const ai = new ONNXSegmentationController({
  listeners: [mlLogger],
  models,
  modelName: 'sam_b',
});

which gives the url to the model files.

Models in binary

You can download the model files and use them offline by moving them to the public folder.

In Webpack you can add the model files to the public folder like this

new CopyPlugin({
  patterns: [
    {
      from:
        '../../../externals/sam_l',
      to: '${destPath.replace(/\\/g, '/')}/sam_l',
    },
    {
      from:
        '../../../externals/sam_h',
      to: '${destPath.replace(/\\/g, '/')}/sam_h',
    },
  ],
}),

, other build systems might have a different way to do this.