{ "cells": [ { "cell_type": "markdown", "id": "bac02017aa438779", "metadata": {}, "source": "# Command Line Usage" }, { "cell_type": "markdown", "id": "736eed409d1d326e", "metadata": {}, "source": [ "Once the **eIQ Vela** package is installed, you can use it like any other command line tool.\n", "The following section demonstrates the basic workflow for converting TF Lite models for use on i.MX 93." ] }, { "cell_type": "markdown", "id": "16871d040f4a165e", "metadata": {}, "source": [ "First, let's prepare the model we want to convert." ] }, { "cell_type": "code", "id": "665aef5b44769bab", "metadata": {}, "source": [ "from pathlib import Path\n", "import requests\n", "\n", "# Change this if you have your own model.\n", "model_path = Path(\"my_path_to_tflite_model.tflite\")" ], "outputs": [], "execution_count": null }, { "cell_type": "code", "id": "cc63268fb63e5418", "metadata": {}, "source": [ "# Alternatively download example model.\n", "example_model_url = \"https://eiq.nxp.com/training-materials/_misc/models/mobilenet_v3-small_224_1.0_uint8.tflite\"\n", "\n", "with open(model_path, \"wb\") as f:\n", " response = requests.get(\n", " url=example_model_url\n", " )\n", " f.write(response.content)\n", "\n", " if response.status_code != 200:\n", " print(f\"Failed to download model: {response.content}\")\n", " else:\n", " print(f\"Model downloaded and saved to {model_path} file.\")" ], "outputs": [], "execution_count": null }, { "cell_type": "markdown", "id": "ab5f67fcb111403", "metadata": {}, "source": [ "The simplest way to run a Vela conversion is to provide the model you want to convert along with an output directory.\n", "After the conversion completes, you’ll find the generated model in the specified directory." ] }, { "cell_type": "code", "id": "48f1f7d3991fd326", "metadata": {}, "source": [ "# Change this to your path\n", "output_dir = Path(\"vela_output_dir\")\n", "!vela --output-dir $output_dir $model_path\n", "\n", "print(f\"Converted model can be found in {output_dir} folder.\")" ], "outputs": [], "execution_count": null }, { "cell_type": "markdown", "id": "1ec8ab4eccf1a7b5", "metadata": {}, "source": [ "There are many additional options available for conversion and model performance analysis.\n", "To see the full list, check the command’s help flag:" ] }, { "cell_type": "code", "id": "99c538d5-0d45-436a-85e1-1c05edc237a8", "metadata": {}, "source": [ "!vela -h" ], "outputs": [], "execution_count": null } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.12" } }, "nbformat": 4, "nbformat_minor": 5 }