Skip to content

ioanbsu/ml_smart_home

Repository files navigation

Machine Learning meets smart home (home assistant): ML-Switch

In this repository you'll find code that allows to train Computer Vision (CV) Machine Learning(ML) model and generate MQTT events that are recognized by Home Assistant as MQTT Switch.

Prerequisites

  1. Mac M1
  2. conda/miniconda
  3. Docker
  4. Home Assistant (HA) installed. While this approach will very likely to work with other smart home solutions, we will be using home assistant in this example. You are more than welcome to try to adopt proposed here solution to different smart home solutions, but using it with home assistant will make following staps in this instruction a lot easier.
  5. MQTT - installed and integrated with HA
  6. Python
  7. Grafana(optional)

Plan

  1. Labeling
    • Start label-studio. Create account, get ready to import
    • Record images to train on
    • Upload images
    • Label images
    • Export images
  2. Env setup
    • Install docker (google it)
    • Install conda (google it). Miniconda will work just fine well
    • Setup conda env in IDEA
    • Init conda env and "attach" it to IDEA
    • Link conda env to jupiter notebook: python -m ipykernel install --user --name ml_smart_home --display-name "ML Smart Home". This step is optional but is recommended, you can just run all commands from cmd line provided you ruin them from appropriate conda environment.
  3. Training
    • Splitting dataset into training, validating and test. Here is a very good explanation why that is needed.
    • Training using yolov8x
  4. Testing
    • Using provided yolo_predict_test.py python script, test that objects detection works as expected
  5. Home automation integration
  6. All-in-one-docker integration.
    • All in one docker file available at docker-complete-solution. To start it run: cd docker-complete-solution; docker-compose up
    • The python code that does object detection and pushing mqtt messages is at docker-complete-solution/ml_docker/ml_mqtt-device.py

Step by step instructions

For complete step-by step instructions check out youtube video

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published