Skip to content

Commit

Permalink
Created using Colab
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbaer committed May 15, 2024
1 parent 376bbad commit c6c1c66
Showing 1 changed file with 148 additions and 0 deletions.
148 changes: 148 additions & 0 deletions quick_start_google_edge.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "Earrbj1HNaVk"
},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-ai-edge/model-explorer/blob/main/example_colabs/quick_start.ipynb)\n",
"\n",
"# Google AI Edge Model Explorer\n",
"A visualization tool that lets you analyze ML models and graphs, accelerating deployment to on-device targets. [Learn more](https://ai.google.dev/edge/model-explorer).\n",
"\n",
"**Key Features**\n",
"\n",
"* Visualize large models effortlessly\n",
"* Find model conversion issues\n",
"* Identify optimization targets\n",
"* Easy to use intuitive UI\n",
"\n",
"Follow the [installation instructions](https://github.com/google-ai-edge/model-explorer/wiki/5.-Run-in-Colab-Notebook) to add it to your own Colab.\n",
"\n",
"Want to run Model Explorer locally? [Get Started here](https://github.com/google-ai-edge/model-explorer/wiki/1.-Installation)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vCM_sxQsg2nj"
},
"source": [
"# Download a copy of the EfficientDet TFLite model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "SmUNdu2jhU1z"
},
"outputs": [],
"source": [
"import os\n",
"import tempfile\n",
"import urllib.request\n",
"import torch\n",
"import torchvision\n",
"\n",
"tmp_path = tempfile.mkdtemp()\n",
"model_path = os.path.join(tmp_path, 'model.tflite')\n",
"urllib.request.urlretrieve(\"https://storage.googleapis.com/tfweb/model-graph-vis-v2-test-models/efficientdet.tflite\", model_path)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nSHa2LHCg7Gz"
},
"source": [
"# Install Model Explorer using pip"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "XqnjhEVqkSvU"
},
"outputs": [],
"source": [
"!pip install ai-edge-model-explorer\n",
"\n",
"# Faster installation by skipping deps that are included in colab runtime:\n",
"# !pip install --no-deps ai-edge-model-explorer-adapter ai-edge-model-explorer"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tNzvaoFHhBJR"
},
"source": [
"# Visualize the downloaded EfficientDet model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "_qycf3tbmP_S"
},
"outputs": [],
"source": [
"import model_explorer\n",
"\n",
"model_explorer.visualize(model_path)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Q3aMYkE6HMPM"
},
"source": [
"# Visualize a PyTorch model\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "sZJkEgdsHSH9"
},
"outputs": [],
"source": [
"# Get mobilnet v2 pytorch model as an example.\n",
"model = torchvision.models.mobilenet_v2().eval()\n",
"inputs = (torch.rand([1, 3, 224, 224]),)\n",
"ep = torch.export.export(model, inputs)\n",
"\n",
"# Visualize\n",
"model_explorer.visualize_pytorch('mobilenet', exported_program=ep)"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [
"vCM_sxQsg2nj",
"nSHa2LHCg7Gz",
"tNzvaoFHhBJR",
"Q3aMYkE6HMPM"
],
"private_outputs": true,
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit c6c1c66

Please sign in to comment.