From 1b5f4fa802d76a3b7572f00a007cf18007d37dd0 Mon Sep 17 00:00:00 2001 From: John Fogarty Date: Tue, 27 Jan 2026 23:11:25 -0800 Subject: [PATCH] Update RubikPi Collab Notebook with working Device (#2339) The RubikPi collab notebook included a device for creating a quantized model that was deprecated by the Qualcomm team. I've included a separate cell with a command to check available devices and updated the command to a known working state. --- scripts/rubik_conversion.ipynb | 175 ++++++++++++++++++--------------- 1 file changed, 95 insertions(+), 80 deletions(-) diff --git a/scripts/rubik_conversion.ipynb b/scripts/rubik_conversion.ipynb index 608c99745..4fccffc9b 100644 --- a/scripts/rubik_conversion.ipynb +++ b/scripts/rubik_conversion.ipynb @@ -1,84 +1,99 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "1tMAqVl4p58r" - }, - "source": [ - "## YOLO to Rubik TFlite Conversion" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "nAbygyUYp58s" - }, - "source": [ - "#### Requirements\n", - "\n", - "This notebook can be run on Colab. However, Colab has some incompatibility issues that result in needing to restart the notebook in the middle of the run. This is normal, and after restarting you should rerun the below cell.\n", - "\n", - "If you aren't using Google Colab, we recommend creating a [Python venv](https://docs.python.org/3/library/venv.html) so that the packages installed for conversion do not conflict with your existing setup.\n", - "\n", - "Prior to running the notebook, it is necessary to make an account on [Qualcomm's AI Hub](https://app.aihub.qualcomm.com/account/), and obtain your API token. Then, replace with your API token in the cell below.\n", - "\n", - "Documentation for the Qualcomm AI Hub can be found [here](https://app.aihub.qualcomm.com/docs/index.html).\n", - "\n", - "You should also have a PyTorch model (ending in `.pt`) that's been uploaded to the runtime that you intend to convert. After uploading, copy it's absolute path by right-clicking on the file, and replace /PATH/TO/WEIGHTS.\n", - "\n", - "**NOTE: your API key will be listed in the output, and should therefore be redacted if the output is shared.**\n", - "\n", - "Once the run has finished, open the AI Hub link, and download the tflite model for the job you just ran.\n", - "\n", - "If you want to use this notebook to convert a yolo11 model, you'll need to replace all instances of `yolov8` in the cell below with `yolov11`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "1tMAqVl4p58r" + }, + "source": [ + "## YOLO to Rubik TFlite Conversion" + ] }, - "id": "aX3JcSFKp58s", - "outputId": "f2cdadd2-c448-4d8c-c681-c19decef7f3e" - }, - "outputs": [], - "source": [ - "# This installs Python package\n", - "!pip install qai-hub-models[yolov8_det]\n", - "# sets up AI Hub enviroment\n", - "!qai-hub configure --api_token \n", - "# Converts the model to be ran on RB3Gen2\n", - "!yes | python -m qai_hub_models.models.yolov8_det.export --quantize w8a8 --device=\"RB3 Gen 2 (Proxy)\" --ckpt-name /PATH/TO/WEIGHTS --device-os linux --target-runtime tflite --output-dir .\n" - ] + { + "cell_type": "markdown", + "metadata": { + "id": "nAbygyUYp58s" + }, + "source": [ + "#### Requirements\n", + "\n", + "This notebook can be run on Colab. However, Colab has some incompatibility issues that result in needing to restart the notebook in the middle of the run. This is normal, and after restarting you should rerun the below cell.\n", + "\n", + "If you aren't using Google Colab, we recommend creating a [Python venv](https://docs.python.org/3/library/venv.html) so that the packages installed for conversion do not conflict with your existing setup.\n", + "\n", + "Prior to running the notebook, it is necessary to make an account on [Qualcomm's AI Hub](https://app.aihub.qualcomm.com/account/), and obtain your API token. Then, replace with your API token in the cell below.\n", + "\n", + "Documentation for the Qualcomm AI Hub can be found [here](https://app.aihub.qualcomm.com/docs/index.html).\n", + "\n", + "You should also have a PyTorch model (ending in `.pt`) that's been uploaded to the runtime that you intend to convert. After uploading, copy it's absolute path by right-clicking on the file, and replace /PATH/TO/WEIGHTS.\n", + "\n", + "**NOTE: your API key will be listed in the output, and should therefore be redacted if the output is shared.**\n", + "\n", + "Once the run has finished, open the AI Hub link, and download the tflite model for the job you just ran.\n", + "\n", + "If you want to use this notebook to convert a yolo11 model, you'll need to replace all instances of `yolov8` in the cell below with `yolov11`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "aX3JcSFKp58s", + "outputId": "7fffa581-fb85-4808-84d6-b737142011b2" + }, + "outputs": [], + "source": [ + "# This installs Python package\n", + "!pip install qai-hub-models[yolov8_det]\n", + "# sets up AI Hub enviroment\n", + "!qai-hub configure --api_token [YOUR API KEY]\n", + "# Converts the model to be ran on RB3Gen2\n", + "!yes | python -m qai_hub_models.models.yolov8_det.export --quantize w8a8 --device=\"Dragonwing RB3 Gen 2 Vision Kit\" --ckpt-name /content/PyTorch_model.pt --device-os 1.6 --target-runtime tflite --output-dir .\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "jl9M3nPDqlue", + "outputId": "2df2c1af-c4ee-4cbf-dad6-7ec3afd28337" + }, + "outputs": [], + "source": [ + "# check valid devices / os types\n", + "!qai-hub list-devices" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0I2cXQO4p58s" + }, + "source": [ + "Modified from https://github.com/ramalamadingdong/yolo-rb3gen2-trainer/blob/main/AI_Hub_Quanitization_RB3Gen2.ipynb" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.11.7" + } }, - { - "cell_type": "markdown", - "metadata": { - "id": "0I2cXQO4p58s" - }, - "source": [ - "Modified from https://github.com/ramalamadingdong/yolo-rb3gen2-trainer/blob/main/AI_Hub_Quanitization_RB3Gen2.ipynb" - ] - } - ], - "metadata": { - "colab": { - "provenance": [] - }, - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.11.7" - } - }, - "nbformat": 4, - "nbformat_minor": 0 + "nbformat": 4, + "nbformat_minor": 0 }