Skip to content

Commit

Permalink
device widget part 2 (openvinotoolkit#2321)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Aug 28, 2024
1 parent faa5036 commit de3046b
Show file tree
Hide file tree
Showing 83 changed files with 903 additions and 721 deletions.
15 changes: 14 additions & 1 deletion notebooks/3D-pose-estimation-webcam/3D-pose-estimation.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "9de9a93e-9247-4799-a5bb-2ec1575ae8c2",
"metadata": {},
Expand Down Expand Up @@ -63,6 +64,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "7925a51b-26ec-43c5-9660-0705c03d724d",
"metadata": {},
Expand All @@ -80,10 +82,11 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install pythreejs \"openvino-dev>=2024.0.0\" \"opencv-python\" \"torch\" \"onnx\" --extra-index-url https://download.pytorch.org/whl/cpu"
"%pip install pythreejs \"openvino-dev>=2024.0.0\" \"opencv-python\" \"torch\" \"onnx<1.16.2\" --extra-index-url https://download.pytorch.org/whl/cpu"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "5a9332fb-1cee-4faa-9555-731ddf0e0df7",
"metadata": {},
Expand Down Expand Up @@ -129,6 +132,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c96ad61a-59ff-4873-b2f3-3994d6826f51",
"metadata": {},
Expand Down Expand Up @@ -170,6 +174,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "88f39f76-2f81-4c18-9fda-98ea6a944220",
"metadata": {},
Expand All @@ -195,6 +200,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6458fe97-6e93-4357-bc9a-16394d962e56",
"metadata": {},
Expand All @@ -218,6 +224,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "986a07ac-d092-4254-848a-dd48f4934fb5",
"metadata": {},
Expand Down Expand Up @@ -252,6 +259,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "5c0ffd17-df71-4178-8df8-db4ccf431621",
"metadata": {},
Expand All @@ -270,6 +278,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "48eb5032-a06e-48c1-a3d6-f0fbad9924fb",
"metadata": {},
Expand Down Expand Up @@ -316,6 +325,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6991403a-4f87-45be-9b3f-d30b23a46dbe",
"metadata": {},
Expand Down Expand Up @@ -425,6 +435,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a6894ce8-ac91-464d-a7f7-54d09f399f4f",
"metadata": {},
Expand Down Expand Up @@ -600,6 +611,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "344840a6-9660-4a11-8b05-729ac2969e28",
"metadata": {},
Expand All @@ -619,6 +631,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "d2d1a143-afcb-4f22-a4cc-657a080b70bf",
"metadata": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@
"%pip install -q \"nncf>=2.9.0\" datasets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c23018e",
"metadata": {},
"outputs": [],
"source": [
"# Fetch the notebook utils script from the openvino_notebooks repo\n",
"import requests\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down Expand Up @@ -496,16 +512,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"from notebook_utils import device_widget\n",
"\n",
"core = ov.Core()\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand All @@ -522,6 +531,8 @@
},
"outputs": [],
"source": [
"core = ov.Core()\n",
"\n",
"ov_text_encoder = core.compile_model(TEXT_ENCODER_OV_PATH, device.value)\n",
"ov_transformer = core.compile_model(TRANSFORMER_OV_PATH, device.value)\n",
"ov_vqvae = core.compile_model(VQVAE_OV_PATH, device.value)"
Expand Down Expand Up @@ -755,10 +766,12 @@
},
"outputs": [],
"source": [
"from notebook_utils import quantization_widget\n",
"\n",
"QUANTIZED_TRANSFORMER_OV_PATH = Path(str(TRANSFORMER_OV_PATH).replace(\".xml\", \"_quantized.xml\"))\n",
"\n",
"skip_for_device = \"GPU\" in device.value\n",
"to_quantize = widgets.Checkbox(value=not skip_for_device, description=\"Quantization\", disabled=skip_for_device)\n",
"to_quantize = quantization_widget(not skip_for_device)\n",
"to_quantize"
]
},
Expand All @@ -774,8 +787,6 @@
},
"outputs": [],
"source": [
"import requests\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/skip_kernel_extension.py\",\n",
")\n",
Expand Down Expand Up @@ -1067,6 +1078,8 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"quantized_model_present = QUANTIZED_TRANSFORMER_OV_PATH.exists()\n",
"\n",
"use_quantized_model = widgets.Checkbox(\n",
Expand All @@ -1085,7 +1098,6 @@
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"from pathlib import Path\n",
"\n",
"if not Path(\"gradio_helper.py\").exists():\n",
Expand Down
16 changes: 8 additions & 8 deletions notebooks/animate-anyone/animate-anyone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/skip_kernel_extension.py\",\n",
")\n",
"open(\"skip_kernel_extension.py\", \"w\").write(r.text)\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"%load_ext skip_kernel_extension"
]
},
Expand Down Expand Up @@ -165,7 +171,6 @@
"from diffusers.image_processor import VaeImageProcessor\n",
"from transformers import CLIPImageProcessor\n",
"import torch\n",
"import ipywidgets as widgets\n",
"\n",
"from src.pipelines.pipeline_pose2vid_long import Pose2VideoPipeline\n",
"from src.utils.util import get_fps, read_frames\n",
Expand Down Expand Up @@ -1116,14 +1121,9 @@
}
],
"source": [
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"from notebook_utils import device_widget\n",
"\n",
"device"
"device = device_widget()"
]
},
{
Expand Down
27 changes: 17 additions & 10 deletions notebooks/bark-text-to-audio/bark-text-to-audio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@
"%pip install -q \"git+https://github.com/suno-ai/bark.git\" --extra-index-url https://download.pytorch.org/whl/cpu"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d44f17c4",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down Expand Up @@ -1020,17 +1035,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"import openvino as ov\n",
"from notebook_utils import device_widget\n",
"\n",
"core = ov.Core()\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@
"import tensorflow_hub as hub\n",
"\n",
"tfds.core.utils.gcs_utils._is_gcs_disabled = True\n",
"os.environ[\"NO_GCE_CHECK\"] = \"true\""
"os.environ[\"NO_GCE_CHECK\"] = \"true\"\n",
"\n",
"import requests\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)"
]
},
{
Expand Down Expand Up @@ -446,16 +453,9 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"core = ov.Core()\n",
"from notebook_utils import device_widget\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand All @@ -470,6 +470,8 @@
},
"outputs": [],
"source": [
"core = ov.Core()\n",
"\n",
"ov_fp32_model = core.read_model(ir_path)\n",
"ov_fp32_model.reshape([1, IMG_SIZE[0], IMG_SIZE[1], 3])\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@
"import torch\n",
"import tqdm\n",
"from PIL import Image\n",
"from transformers import CLIPModel, CLIPProcessor"
"from transformers import CLIPModel, CLIPProcessor\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)"
]
},
{
Expand Down Expand Up @@ -640,14 +645,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"from notebook_utils import device_widget\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@
"if platform.system() != \"Windows\":\n",
" %pip install -q \"matplotlib>=3.4\"\n",
"else:\n",
" %pip install -q \"matplotlib>=3.4,<3.7\""
" %pip install -q \"matplotlib>=3.4,<3.7\"\n",
"\n",
"import requests\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)"
]
},
{
Expand Down Expand Up @@ -325,14 +332,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"from notebook_utils import device_widget\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
Loading

0 comments on commit de3046b

Please sign in to comment.