Ultralytics YOLO banner

[中文](https://docs.ultralytics.com/zh) | [한국어](https://docs.ultralytics.com/ko) | [日本語](https://docs.ultralytics.com/ja) | [Русский](https://docs.ultralytics.com/ru) | [Deutsch](https://docs.ultralytics.com/de) | [Français](https://docs.ultralytics.com/fr) | [Español](https://docs.ultralytics.com/es) | [Português](https://docs.ultralytics.com/pt) | [Türkçe](https://docs.ultralytics.com/tr) | [Tiếng Việt](https://docs.ultralytics.com/vi) | [العربية](https://docs.ultralytics.com/ar)
# Ultralytics YOLO npm Inference
[English](README.md) | [简体中文](README.zh-CN.md)
[![npm version](https://img.shields.io/npm/v/@ultralytics/yolo?logo=npm&logoColor=white&label=npm&color=CB3837)](https://www.npmjs.com/package/@ultralytics/yolo) [![npm downloads](https://img.shields.io/npm/dm/@ultralytics/yolo?logo=npm&logoColor=white&label=downloads&color=CB3837)](https://www.npmjs.com/package/@ultralytics/yolo) [![CI](https://github.com/ultralytics/inference/actions/workflows/ci.yml/badge.svg)](https://github.com/ultralytics/inference/actions/workflows/ci.yml) [![License](https://img.shields.io/npm/l/@ultralytics/yolo?label=license&color=blue)](https://github.com/ultralytics/inference/blob/main/LICENSE) [![arXiv](https://img.shields.io/badge/arXiv-2606.03748-b31b1b?logo=arxiv&logoColor=white)](https://arxiv.org/abs/2606.03748) [![Ultralytics Discord](https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue)](https://discord.com/invite/ultralytics) [![Ultralytics Forums](https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue)](https://community.ultralytics.com/) [![Ultralytics Reddit](https://img.shields.io/reddit/subreddit-subscribers/ultralytics?style=flat&logo=reddit&logoColor=white&label=Reddit&color=blue)](https://www.reddit.com/r/Ultralytics/)
Run [Ultralytics](https://www.ultralytics.com/) YOLO models directly in the browser, with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm fallback) and covers detection, segmentation, pose, classification, OBB, semantic segmentation, and depth estimation, behind a small TypeScript API with a built-in `annotate()` that draws results straight to a canvas. ```ts import { YOLO, annotate } from "@ultralytics/yolo"; const model = await YOLO.load("yolo26n.onnx"); const results = await model.predict("bus.jpg"); await annotate(document.querySelector("canvas"), "bus.jpg", results); ``` It is a **library only** (no CLI; that is the native Rust crate). Under the hood the engine is the `ultralytics-inference` Rust crate compiled to WebAssembly. Inference runs on [ONNX Runtime Web](https://onnxruntime.ai/docs/tutorials/web/) via [`ort-web`](https://ort.pyke.io/backends/web), and all pre/postprocessing, colors, and the pose skeleton come from that shared Rust code, so results and visuals match the native and Python paths. ## 📦 Install ```bash npm install @ultralytics/yolo # or pnpm add @ultralytics/yolo yarn add @ultralytics/yolo bun add @ultralytics/yolo ``` It ships as an ES module with TypeScript types and works in any modern bundler (Vite, webpack, esbuild, Bun) or directly via a CDN such as [esm.sh](https://esm.sh/@ultralytics/yolo). ## 🚀 Quick Start ```ts import { YOLO, annotate } from "@ultralytics/yolo"; // Loads the model and initializes WebGPU + ONNX Runtime Web on first use. const model = await YOLO.load("yolo26n.onnx"); const results = await model.predict("bus.jpg"); for (const box of results.boxes) { console.log(box.name, box.conf.toFixed(2), [box.x1, box.y1, box.x2, box.y2]); } // Draw boxes, OBB, pose, and labels onto a canvas in one call (no canvas code). await annotate(document.querySelector("canvas"), "bus.jpg", results); ``` `predict()` accepts a URL/path, a `Blob`/`File`, raw encoded image bytes (`Uint8Array`/`ArrayBuffer`), `ImageData`, an `HTMLImageElement`, `HTMLCanvasElement`, `HTMLVideoElement`, or an `ImageBitmap`. ```ts const results = await model.predict(canvas, { conf: 0.25, iou: 0.7 }); console.log(model.device); // "webgpu" or "cpu" ``` `YOLO.load` also takes a `Blob`/`File`, so you can load a model the user drops or picks. The backend is detected from the bytes, so the same call handles `.onnx` and `.tflite`: ```ts const model = await YOLO.load(fileInput.files[0]); // a dropped/picked .onnx or .tflite ``` ### Webcam / Video Drawable sources (`