Skip to content

Commit

Permalink
device widget part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Aug 26, 2024
1 parent 350672e commit 6acde38
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 144 deletions.
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,8 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\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",
"from notebook_utils import device_widget\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand All @@ -522,6 +530,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 +765,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 +786,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 @@ -1085,7 +1095,6 @@
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"from pathlib import Path\n",
"\n",
"if not Path(\"gradio_helper.py\").exists():\n",
Expand Down
15 changes: 8 additions & 7 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 @@ -1116,14 +1122,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
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@
"source": [
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"torch>=2.1\" \"torchvision\"\n",
"%pip install -q \"diffusers>=0.14.0\" \"transformers>=4.30.2\" \"controlnet-aux>=0.0.6\" \"gradio>=3.36\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q \"openvino>=2023.1.0\" \"datasets>=2.14.6\" \"nncf>=2.7.0\""
"%pip install -q \"openvino>=2023.1.0\" \"datasets>=2.14.6\" \"nncf>=2.7.0\"\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 @@ -447,14 +454,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 Expand Up @@ -1375,16 +1377,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"core = ov.Core()\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget(\"CPU\")\n",
"\n",
"device"
]
Expand Down Expand Up @@ -1493,7 +1488,9 @@
}
],
"source": [
"to_quantize = widgets.Checkbox(value=True, description=\"Quantization\")\n",
"from notebook_utils import quantization_widget\n",
"\n",
"to_quantize = quantization_widget()\n",
"\n",
"to_quantize"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
"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)\n",
"\n",
"def get_book_by_id(book_id: int, gutendex_url: str = \"https://gutendex.com/\") -> str:\n",
" book_metadata_url = gutendex_url + \"/books/\" + str(book_id)\n",
Expand Down Expand Up @@ -627,15 +631,9 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"from notebook_utils import device_widget\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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@
"source": [
"import sys\n",
"from pathlib import Path\n",
"import requests\n",
"\n",
"repo_dir = Path(\"DDColor\")\n",
"\n",
"if not repo_dir.exists():\n",
" !git clone https://github.com/piddnad/DDColor.git\n",
"\n",
"sys.path.append(str(repo_dir))"
"sys.path.append(str(repo_dir))\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 @@ -277,16 +283,11 @@
}
],
"source": [
"import ipywidgets as widgets\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
Loading

0 comments on commit 6acde38

Please sign in to comment.