Skip to content

Commit

Permalink
part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Aug 23, 2024
1 parent 7644fef commit cdb9abf
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 131 deletions.
11 changes: 1 addition & 10 deletions notebooks/paddle-ocr-webcam/paddle-ocr-webcam.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,7 @@
}
],
"source": [
"import ipywidgets as widgets\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 = utils.device_widget()\n",
"\n",
"device"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file, device_widget"
]
},
{
Expand Down Expand Up @@ -426,15 +426,8 @@
}
],
"source": [
"import ipywidgets as widgets\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 Down
25 changes: 6 additions & 19 deletions notebooks/paint-by-example/paint-by-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget, quantization_widget\n",
"\n",
"download_file(\n",
" \"https://github-production-user-asset-6210df.s3.amazonaws.com/103226580/286377210-edc98e97-0e43-4796-b771-dacd074c39ea.png\",\n",
Expand Down Expand Up @@ -857,17 +857,7 @@
}
],
"source": [
"from openvino import Core\n",
"import ipywidgets as widgets\n",
"\n",
"core = 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 Expand Up @@ -896,6 +886,7 @@
"source": [
"ov_config = {\"INFERENCE_PRECISION_HINT\": \"f32\"} if device.value != \"CPU\" else {}\n",
"\n",
"core = ov.Core()\n",
"\n",
"def get_ov_pipeline():\n",
" image_encoder_inpaint = core.compile_model(IMAGE_ENCODER_OV_PATH_INPAINT, device.value)\n",
Expand Down Expand Up @@ -961,17 +952,11 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"UNET_INT8_OV_PATH = Path(\"model/unet_int8.xml\")\n",
"int8_ov_pipe_inpaint = None\n",
"\n",
"\n",
"to_quantize = widgets.Checkbox(\n",
" value=True,\n",
" description=\"Quantization\",\n",
" disabled=False,\n",
")\n",
"to_quantize = quantization_widget()\n",
"\n",
"to_quantize"
]
Expand Down Expand Up @@ -1527,6 +1512,8 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"available_models = [\"FP16\"]\n",
"\n",
"if UNET_INT8_OV_PATH.exists():\n",
Expand Down
9 changes: 1 addition & 8 deletions notebooks/person-tracking-webcam/person-tracking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,7 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = utils.device_widget()\n",
"\n",
"device"
]
Expand Down
12 changes: 2 additions & 10 deletions notebooks/pose-estimation-webcam/pose-estimation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,7 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\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 = utils.device_widget()\n",
"\n",
"device"
]
Expand Down Expand Up @@ -197,6 +188,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file, device_widget"
]
},
{
Expand Down Expand Up @@ -761,15 +761,7 @@
}
],
"source": [
"import ipywidgets as widgets\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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"torch.manual_seed(0)\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
Expand Down Expand Up @@ -1039,16 +1039,7 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"# Initialize OpenVINO runtime\n",
"core = ov.Core()\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices,\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down Expand Up @@ -1117,6 +1108,7 @@
}
],
"source": [
"core = ov.Core()\n",
"core.get_property(device.value, \"FULL_DEVICE_NAME\")"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"DATA_DIR = Path(\"data\")\n",
"\n",
Expand Down Expand Up @@ -658,16 +658,11 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"\n",
"\n",
"# Initialize OpenVINO runtime\n",
"core = ov.Core()\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices,\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
10 changes: 2 additions & 8 deletions notebooks/pytorch-to-openvino/pytorch-onnx-to-openvino.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
" SegmentationMap,\n",
" Label,\n",
" download_file,\n",
" device_widget\n",
")"
]
},
Expand Down Expand Up @@ -470,14 +471,7 @@
}
],
"source": [
"import ipywidgets as widgets\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 @@ -129,7 +129,7 @@
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file, device_widget"
]
},
{
Expand Down Expand Up @@ -698,16 +698,7 @@
}
],
"source": [
"import ipywidgets as widgets\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
11 changes: 2 additions & 9 deletions notebooks/segment-anything/segment-anything.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"checkpoint = \"sam_vit_b_01ec64.pth\"\n",
"model_url = \"https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth\"\n",
Expand Down Expand Up @@ -243,14 +243,7 @@
}
],
"source": [
"import ipywidgets as widgets\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
10 changes: 2 additions & 8 deletions notebooks/softvc-voice-conversion/softvc-voice-conversion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"# ContentVec\n",
"download_file(\n",
Expand Down Expand Up @@ -332,17 +332,11 @@
},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"import openvino as ov\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 @@ -117,7 +117,7 @@
"if not Path(\"notebook_utils.py\").exists():\n",
" r = requests.get(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\")\n",
" open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"IMAGE_WIDTH = 512\n",
"IMAGE_HEIGHT = 512\n",
Expand Down Expand Up @@ -544,15 +544,7 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"import openvino as ov\n",
"\n",
"device = widgets.Dropdown(\n",
" options=ov.Core().available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand All @@ -573,6 +565,8 @@
},
"outputs": [],
"source": [
"import openvino as ov\n",
"\n",
"core = ov.Core()\n",
"ov_text_encoder = core.compile_model(OV_TEXT_ENCODER_MODEL_PATH, device.value)\n",
"ov_diffusion_model = core.compile_model(OV_DIFFUSION_MODEL_PATH, device.value)\n",
Expand Down

0 comments on commit cdb9abf

Please sign in to comment.