explaingit

armanbilge/onnx-scala

Analysis updated 2026-08-16 · repo last pushed 2023-03-15

Audience · developerComplexity · 3/5DormantSetup · moderate

TLDR

Run pre-trained machine learning models directly inside Scala apps without needing Python. Load a model file, pass in data, and get predictions back on the JVM, in JavaScript, or via Scala Native.

Mindmap

mindmap
  root((repo))
    What it does
      Runs ML models in Scala
      Loads ONNX model files
      Returns typed predictions
    Tech stack
      Scala 3
      ONNX Runtime
      Scala.js
      Scala Native
    Use cases
      Image classification in Scala
      In-browser ML predictions
      Server-side model inference
    Audience
      Scala developers
      JVM application builders
    Key features
      Compile-time shape checking
      Cross-platform support
      No Python required

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run an image classifier like SqueezeNet inside a Scala backend and get predicted categories without calling Python.

USE CASE 2

Load and run ONNX models in a browser using Scala.js for client-side predictions.

USE CASE 3

Run machine learning inference on a server using Scala Native for native performance without a JVM.

What is it built with?

Scala 3ONNX RuntimeScala.jsScala NativeJVM

How does it compare?

armanbilge/onnx-scala000madz000/rfid-attendance00kaku/gallery-slider-block
LanguageTypeScriptJavaScript
Last pushed2023-03-152024-07-222021-05-19
MaintenanceDormantDormantDormant
Setup difficultymoderateeasyeasy
Complexity3/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires an ONNX model file to load and basic familiarity with tensor shapes, cross-platform setup may require choosing the right Scala backend.

No license information was provided in the explanation, so the licensing terms are unknown.

In plain English

ONNX-Scala lets you run pre-trained machine learning models from inside a Scala application. Instead of writing a separate Python script or service to do inference, you load a model file directly in your Scala code, feed it data, and get predictions back, all without leaving your JVM or JavaScript environment. At its core, the project wraps ONNX Runtime, Microsoft's engine for running trained models. You point it at a model file (like an image classifier), pass in your input data as a typed tensor (think of a tensor as a multi-dimensional array with labels like "Batch," "Channel," "Height," and "Width"), and call a method to run the model. The output comes back as another tensor with its own shape and labels. The project also offers a lower-level API for building models piece by piece, but the simplest path is loading a whole model file and letting the runtime optimize it. The main audience is Scala developers who want to use existing ONNX models without bridging to Python. For example, if you have a SqueezeNet model that classifies images into ImageNet categories, you can load the model, pass in an image array, and get back the predicted class index, all in Scala. The README notes that performance is within 3% of calling ONNX Runtime from Python directly, with the small gap coming from moving data between the JVM and native memory. One notable aspect is the type system. The project uses Scala 3 features to encode tensor shapes and axis labels at the compile-time level, meaning the compiler can catch shape mismatches before your code runs. The full-model API is more loosely typed on the input side since models are loaded from disk at runtime, but outputs are still typed. It also runs across multiple Scala platforms: the JVM, Scala.js (JavaScript), and Scala Native, so the same model-loading code can work in a browser or on a server. Training support is not yet available, the project currently focuses on inference (running predictions with existing models).

Copy-paste prompts

Prompt 1
Show me how to load a SqueezeNet ONNX model in Scala and pass in an image tensor to get a predicted class index using onnx-scala.
Prompt 2
How do I create a typed tensor with labeled axes like Batch, Channel, Height, and Width in onnx-scala so the compiler checks my shapes?
Prompt 3
Write a Scala.js example that loads an ONNX model file and runs inference in the browser using onnx-scala.
Prompt 4
Compare the high-level model-loading API and the low-level model-building API in onnx-scala with a simple code example.

Frequently asked questions

What is onnx-scala?

Run pre-trained machine learning models directly inside Scala apps without needing Python. Load a model file, pass in data, and get predictions back on the JVM, in JavaScript, or via Scala Native.

Is onnx-scala actively maintained?

Dormant — no commits in 2+ years (last push 2023-03-15).

What license does onnx-scala use?

No license information was provided in the explanation, so the licensing terms are unknown.

How hard is onnx-scala to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is onnx-scala for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.