alvises

alvises

YOLO - Real-Time Object Detection Simplified

Hello everyone! :waving_hand:

I’m excited to introduce my first Elixir library: YOLO, a library designed to make real-time object detection accessible and efficient within the Elixir ecosystem. Whether you’re working on a hobby project or a production-grade application, this library provides a simple way to integrate the power of YOLO (You Only Look Once) object detection.

What is YOLO?

YoloV8x

YOLO is a state-of-the-art system for detecting objects in images or videos. It is widely used for applications like monitoring, automation, and robotics due to its balance of speed and accuracy. YOLO enables developers to use YOLO models seamlessly in Elixir, with a focus on ease of use and extensibility.

Key Features

  • Speed: Optimized for real-time performance, processing an image. with the YoloV8n model, to a list of detected objects in just 38ms on a MacBook Air M3 using EXLA and the companion library YoloFastNMS.
  • Ease of Use: Get started with just a two function calls to load models and detect objects.
  • Extensibility: Built around a YOLO.Model behavior, supporting YOLOv8 models and paving the way for future models or custom extensions.
  • NIF Optimization: For those needing ultra-fast post-processing, an optional Rust NIF (YoloFastNMS) speeds up Non-Maximum Suppression by ~100x compared to the internal YOLO.NMS implementation using Elixir and Nx.

How to Get Started

  1. Begin by generating the ONNX model using the provided Python script. Here’s how to do it.
  2. Install the library and call YOLO.load/1 to load model effortlessly.
  3. Load an image and perform object detection with a single call to YOLO.detect/3

It’s that straightforward! :rocket:

Current Limitations and Future Plans

The current implementation supports YOLOv8 models with a fixed 640x640 input size (even though YOLOv8x6 supports 1280x1280 images) and a fixed 84x8400 output size. This setup handles 80 classes from the COCO dataset and 8400 detections.

The library is designed to be extensible through the YOLO.Model behaviour, allowing other YOLO versions or custom model implementations to be added in the near future.

One of the next goals is to support models with different input and output sizes. This update would allow the library to work with YOLO models trained on other datasets or even custom datasets, making it more flexible and useful.

Links

Most Liked

alvises

alvises

I recorded a from-scratch walkthrough of fine-tuning a YOLOX model for car license-plate detection. Now that YOLO Elixir library supports YOLOX models, this guide helps anyone who wants to build custom YOLOX models and then bring them into the Elixir ecosystem.

We go end to end: setting up the environment and YOLOX, finding and preparing a public dataset, training, evaluate the metrics, running inference on dashcam footage, and comparing results with an Ultralytics YOLO11 model trained on the same data. It is a long, almost live session, since YOLOX relies on older dependencies and I show the real troubleshooting and small script fixes needed to make it work. Once it is set up, performance is strong and on par with Ultralytics.

alvises

alvises

I promised myself to make a quick 5-10 min video showcasing how the YOLO library works… ended up with a 36-minute deep dive! Turns out I get a bit carried away when talking about object detection. :sweat_smile:

But hey, at least you get to see everything from basic usage to performance optimization, live demos, and future plans. Hope you find it useful despite my complete failure at being concise!

11
Post #3
alvises

alvises

Since the YOLO library now finally supports custom models, I created a guide showing how to fine-tune YOLO models for your specific use cases. The guide demonstrates transforming a generic 80-class detector into a specialized system (using soccer match analysis as an example) and integrating it with the Elixir YOLO library.

Perfect for anyone looking to move beyond the standard COCO dataset and create domain-specific detectors for their applications.

alvises

alvises

I’ve finally released YOLO v0.2.0 :tada:

In short:

  • YOLOX support
  • Model-agnostic postprocessing → AKA Custom Models!
  • Big performance improvement
alvises

alvises

Yes, exactly! I was able to move part of the postprocessing to use Nx.Defn, which compiles to much faster native code.

The YOLO model outputs a huge tensor - typically {8400, 84} where there are 8400 detection candidates, each with 4 bounding box coordinates plus 80 class probabilities. The postprocessing filters this down from 8400 candidates to maybe 40-50 actual detections (before NMS step).

Previously I couldn’t use Nx.Defn for this filtering because the output size is dynamic - you don’t know ahead of time how many detections will pass the probability threshold. Nx.Defn needs to know tensor shapes at compile time. For this reason, between multiple Nx calls the data was going back to Elixir, which also was probably a big part of the slow down.

For this release, I figured out (with the big help of @polvalente :folded_hands:) how to work around that limitation and get the filtering logic into Nx.Defn. That’s where the big performance boost comes from - the difference between interpreted Nx operations and compiled native code.

Here’s the conversation between Paulo and me about this: Slack

Where Next?

Popular in Announcing Top

zachdaniel
Hey folks! AshEvents Release We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps. Check o...
New
Schultzer
Hey there, I wrote this low-level library recently, its goal is simply to lower the barrier between Elixir and SQL, and it does that by p...
New
alvises
Hello everyone! :waving_hand: I’m excited to introduce my first Elixir library: YOLO, a library designed to make real-time object detect...
New
MRdotB
Greetings Elixir community! Today, I’m thrilled to present you with resvg_nif, an open-source project that provides Elixir bindings for ...
New
kasvith
Hello Everyone, I was working with some HTML-to-Markdown libraries and ran into a few issues when converting a complex markup file to Ma...
New
Zurga
Subscribe to events emitted by EctoWatch, and cache the changed row. Use the sync/3 function to update an in-memory row or list of rows u...
New
johantell
Ever struggled with mocking external HTTP services in Elixir tests? Found yourself writing brittle mocks that don’t catch real-world enco...
New
victor23k
LiveViewPortal is a small library that allows third-party sites to embed LiveView apps. The library is distributed as an NPM package. On...
New
leandrocp
MDEx is a fast and extensible Markdown parser and formatter. Fast Leverage Rust to parse, manipulate and render documents using: comra...
New
jallum
Hey folks :waving_hand: I’ve been building a distributed key-value store in Elixir/OTP called Bedrock. It implements FoundationDB’s arch...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement