Skip to content

Commit aba796c

Browse files
authored
Resolve device selection issues part1 (#1737)
1 parent c0490b4 commit aba796c

File tree

15 files changed

+1131
-793
lines changed

15 files changed

+1131
-793
lines changed

notebooks/002-openvino-api/002-openvino-api.ipynb

Lines changed: 191 additions & 148 deletions
Large diffs are not rendered by default.

notebooks/004-hello-detection/004-hello-detection.ipynb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"`(x_min, y_min)` are the coordinates of the top left bounding box corner, `(x_max, y_max)` are the coordinates of the bottom right bounding box corner and `conf` is the confidence for the predicted class.\n",
1414
"\n",
1515
"\n",
16-
"#### Table of contents:\n\n",
16+
"#### Table of contents:\n",
17+
"\n",
1718
"- [Imports](#Imports)\n",
1819
"- [Download model weights](#Download-model-weights)\n",
1920
"- [Select inference device](#Select-inference-device)\n",
@@ -204,7 +205,7 @@
204205
"core = ov.Core()\n",
205206
"\n",
206207
"model = core.read_model(model=model_xml_path)\n",
207-
"compiled_model = core.compile_model(model=model, device_name=\"CPU\")\n",
208+
"compiled_model = core.compile_model(model=model, device_name=device.value)\n",
208209
"\n",
209210
"input_layer_ir = compiled_model.input(0)\n",
210211
"output_layer_ir = compiled_model.output(\"boxes\")"
@@ -389,7 +390,7 @@
389390
"name": "python",
390391
"nbconvert_exporter": "python",
391392
"pygments_lexer": "ipython3",
392-
"version": "3.10.12"
393+
"version": "3.8.10"
393394
},
394395
"openvino_notebooks": {
395396
"imageUrl": "https://user-images.githubusercontent.com/36741649/128489933-bf215a3f-06fa-4918-8833-cb0bf9fb1cc7.jpg",
@@ -403,8 +404,15 @@
403404
"Object Detection"
404405
]
405406
}
407+
},
408+
"widgets": {
409+
"application/vnd.jupyter.widget-state+json": {
410+
"state": {},
411+
"version_major": 2,
412+
"version_minor": 0
413+
}
406414
}
407415
},
408416
"nbformat": 4,
409417
"nbformat_minor": 5
410-
}
418+
}

notebooks/102-pytorch-to-openvino/102-pytorch-onnx-to-openvino.ipynb

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"More information about the model is available in the [torchvision documentation](https://pytorch.org/vision/main/models/lraspp.html)\n",
2525
"\n",
2626
"\n",
27-
"#### Table of contents:\n\n",
27+
"#### Table of contents:\n",
28+
"\n",
2829
"- [Preparation](#Preparation)\n",
2930
" - [Imports](#Imports)\n",
3031
" - [Settings](#Settings)\n",
@@ -777,50 +778,27 @@
777778
" f\"FPS: {num_images/time_torch:.2f}\"\n",
778779
")\n",
779780
"\n",
780-
"compiled_model_onnx = core.compile_model(model=model_onnx, device_name=\"CPU\")\n",
781+
"compiled_model_onnx = core.compile_model(model=model_onnx, device_name=device.value)\n",
781782
"start = time.perf_counter()\n",
782783
"for _ in range(num_images):\n",
783784
" compiled_model_onnx([normalized_input_image])\n",
784785
"end = time.perf_counter()\n",
785786
"time_onnx = end - start\n",
786787
"print(\n",
787-
" f\"ONNX model in OpenVINO Runtime/CPU: {time_onnx/num_images:.3f} \"\n",
788+
" f\"ONNX model in OpenVINO Runtime/{device.value}: {time_onnx/num_images:.3f} \"\n",
788789
" f\"seconds per image, FPS: {num_images/time_onnx:.2f}\"\n",
789790
")\n",
790791
"\n",
791-
"compiled_model_ir = core.compile_model(model=model_ir, device_name=\"CPU\")\n",
792+
"compiled_model_ir = core.compile_model(model=model_ir, device_name=device.value)\n",
792793
"start = time.perf_counter()\n",
793794
"for _ in range(num_images):\n",
794795
" compiled_model_ir([input_image])\n",
795796
"end = time.perf_counter()\n",
796797
"time_ir = end - start\n",
797798
"print(\n",
798-
" f\"OpenVINO IR model in OpenVINO Runtime/CPU: {time_ir/num_images:.3f} \"\n",
799+
" f\"OpenVINO IR model in OpenVINO Runtime/{device.value}: {time_ir/num_images:.3f} \"\n",
799800
" f\"seconds per image, FPS: {num_images/time_ir:.2f}\"\n",
800-
")\n",
801-
"\n",
802-
"if \"GPU\" in core.available_devices:\n",
803-
" compiled_model_onnx_gpu = core.compile_model(model=model_onnx, device_name=\"GPU\")\n",
804-
" start = time.perf_counter()\n",
805-
" for _ in range(num_images):\n",
806-
" compiled_model_onnx_gpu([input_image])\n",
807-
" end = time.perf_counter()\n",
808-
" time_onnx_gpu = end - start\n",
809-
" print(\n",
810-
" f\"ONNX model in OpenVINO/GPU: {time_onnx_gpu/num_images:.3f} \"\n",
811-
" f\"seconds per image, FPS: {num_images/time_onnx_gpu:.2f}\"\n",
812-
" )\n",
813-
"\n",
814-
" compiled_model_ir_gpu = core.compile_model(model=model_ir, device_name=\"GPU\")\n",
815-
" start = time.perf_counter()\n",
816-
" for _ in range(num_images):\n",
817-
" compiled_model_ir_gpu([input_image])\n",
818-
" end = time.perf_counter()\n",
819-
" time_ir_gpu = end - start\n",
820-
" print(\n",
821-
" f\"IR model in OpenVINO/GPU: {time_ir_gpu/num_images:.3f} \"\n",
822-
" f\"seconds per image, FPS: {num_images/time_ir_gpu:.2f}\"\n",
823-
" )"
801+
")\n"
824802
]
825803
},
826804
{
@@ -872,7 +850,7 @@
872850
],
873851
"metadata": {
874852
"kernelspec": {
875-
"display_name": "Python 3",
853+
"display_name": "Python 3 (ipykernel)",
876854
"language": "python",
877855
"name": "python3"
878856
},
@@ -886,7 +864,7 @@
886864
"name": "python",
887865
"nbconvert_exporter": "python",
888866
"pygments_lexer": "ipython3",
889-
"version": "3.11.5"
867+
"version": "3.8.10"
890868
},
891869
"openvino_notebooks": {
892870
"imageUrl": "https://user-images.githubusercontent.com/29454499/203723317-1716e3ca-b390-47e1-bb98-07b4d8d097a0.png",
@@ -905,8 +883,15 @@
905883
"interpreter": {
906884
"hash": "e0404472fd7b5b63117a9fa5c50283296e2708c2449c6090d2cdf8903f95897f"
907885
}
886+
},
887+
"widgets": {
888+
"application/vnd.jupyter.widget-state+json": {
889+
"state": {},
890+
"version_major": 2,
891+
"version_minor": 0
892+
}
908893
}
909894
},
910895
"nbformat": 4,
911896
"nbformat_minor": 5
912-
}
897+
}

notebooks/103-paddle-to-openvino/103-paddle-to-openvino-classification.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"Source of the [model](https://www.paddlepaddle.org.cn/hubdetail?name=mobilenet_v3_large_imagenet_ssld&en_category=ImageClassification).\n",
1515
"\n",
1616
"\n",
17-
"#### Table of contents:\n\n",
17+
"#### Table of contents:\n",
18+
"\n",
1819
"- [Preparation](#Preparation)\n",
1920
" - [Imports](#Imports)\n",
2021
" - [Settings](#Settings)\n",
@@ -458,7 +459,7 @@
458459
"# Load OpenVINO Runtime and OpenVINO IR model\n",
459460
"core = ov.Core()\n",
460461
"model = core.read_model(model_xml)\n",
461-
"compiled_model = core.compile_model(model=model, device_name=\"CPU\")\n",
462+
"compiled_model = core.compile_model(model=model, device_name=device.value)\n",
462463
"\n",
463464
"# Get model output\n",
464465
"output_layer = compiled_model.output(0)\n",
@@ -711,7 +712,7 @@
711712
"name": "python",
712713
"nbconvert_exporter": "python",
713714
"pygments_lexer": "ipython3",
714-
"version": "3.10.12"
715+
"version": "3.8.10"
715716
},
716717
"openvino_notebooks": {
717718
"imageUrl": "https://user-images.githubusercontent.com/77325899/127503530-72c8ce57-ef6f-40a7-808a-d7bdef909d11.png",
@@ -741,4 +742,4 @@
741742
},
742743
"nbformat": 4,
743744
"nbformat_minor": 5
744-
}
745+
}

0 commit comments

Comments
 (0)