Local on-demand image classification for Home Assistant automations

I created a Home Assistant app for local image classification, so the classification result can be used directly inside Home Assistant automations.

You’re asking what this is and how you can use it?

When I developed my smart mailbox, I wanted to receive a notification when the mailbox door closed and there was actually mail inside.

If mail is detected, Home Assistant sends a “You’ve got mail” notification and turns on a physical mail indicator. If the mailbox is empty, nothing happens.

That was the reason I created the Home Assistant app Image Classifier RFHOG.

Why on-demand image classification?

What I like about this approach is that AI/image classification does not need to run continuously.

A cheap physical sensor determines when something interesting happened. Only then does Home Assistant take an image and ask the classifier what happened.

Sensors determine WHEN something happened.
Image classification determines WHAT happened.

The classifier runs locally, so no cloud AI API, subscription or external LLM is required.

Train it with your own images

The documentation includes a Jupyter Notebook that lets you train your own classifier using images from your own camera.

RFHOG is particularly suited to fixed-camera, fixed-scene, few-class problems, where the visual state changes in a predictable way.

Some possible examples:

  • Mailbox / parcel box: empty vs occupied
  • Parking space: free vs occupied
  • Garage: car present vs absent
  • Workshop: tool present vs missing
  • Shelf / fridge: stocked vs empty
  • Gate / barrier: open vs closed
  • Laundry basket / trash bin: empty vs full
  • Bike storage: bike present vs absent
  • Pet or chicken area: occupied vs empty

It doesn’t try to be a general-purpose vision system. Its niche is answering a small, specific visual question about a known scene when a Home Assistant automation needs the answer.

RFHOG vs. Frigate

They solve somewhat different problems:

Frigate: continuous object detection and tracking in video.
RFHOG: lightweight, on-demand classification of a known scene.

I actually use both in my mailbox project.

Video

Here is the complete example in action:

Code, installation and training guide

You can also add the repository directly to Home Assistant:

Open your Home Assistant instance and add the Smart Home Rewired app repository

I’d be very interested in other applications for this approach.

Where would you use on-demand image classification in a Home Assistant automation?

Feedback, ideas and improvements are very welcome!

Phil

3 Likes