1
1
{
2
2
"cells" : [
3
3
{
4
- "attachments" : {},
5
4
"cell_type" : " markdown" ,
6
5
"metadata" : {},
7
6
"source" : [
20
19
" > **NOTE**: This notebook requires that a C++ compiler is accessible on the default binary search path of the OS you are running the notebook.\n " ,
21
20
" \n " ,
22
21
" \n " ,
23
- " #### Table of contents:\n\n " ,
22
+ " #### Table of contents:\n " ,
23
+ " \n " ,
24
24
" - [Preparations](#Preparations)\n " ,
25
25
" - [Imports](#Imports)\n " ,
26
26
" - [Settings](#Settings)\n " ,
38
38
]
39
39
},
40
40
{
41
- "attachments" : {},
42
41
"cell_type" : " markdown" ,
43
42
"metadata" : {},
44
43
"source" : [
53
52
"outputs" : [],
54
53
"source" : [
55
54
" # Install openvino package\n " ,
56
- " %pip install -q \" openvino>=2023.1.0\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu\n " ,
57
- " %pip install -q \" nncf>=2.6.0\" "
58
- ]
59
- },
60
- {
61
- "cell_type" : " code" ,
62
- "execution_count" : 2 ,
63
- "metadata" : {
64
- "scrolled" : true ,
65
- "tags" : []
66
- },
67
- "outputs" : [],
68
- "source" : [
69
- " # On Windows, this script adds the directory that contains cl.exe to the PATH to enable PyTorch to find the\n " ,
70
- " # required C++ tools. This code assumes that Visual Studio 2019 is installed in the default\n " ,
71
- " # directory. If you have a different C++ compiler, add the correct path to os.environ[\" PATH\" ]\n " ,
72
- " # directly.\n " ,
73
- " \n " ,
74
- " # Adding the path to os.environ[\" LIB\" ] is not always required - it depends on the system configuration.\n " ,
75
- " \n " ,
76
- " import sys\n " ,
77
- " \n " ,
78
- " if sys.platform == \" win32\" :\n " ,
79
- " import distutils.command.build_ext\n " ,
80
- " import os\n " ,
81
- " from pathlib import Path\n " ,
82
- " \n " ,
83
- " VS_INSTALL_DIR = r\" C:/Program Files (x86)/Microsoft Visual Studio\"\n " ,
84
- " cl_paths = sorted(list(Path(VS_INSTALL_DIR).glob(\" **/Hostx86/x64/cl.exe\" )))\n " ,
85
- " if len(cl_paths) == 0:\n " ,
86
- " raise ValueError(\n " ,
87
- " \" Cannot find Visual Studio. This notebook requires C++. If you installed \"\n " ,
88
- " \" a C++ compiler, please add the directory that contains cl.exe to \"\n " ,
89
- " \" `os.environ['PATH']`\"\n " ,
90
- " )\n " ,
91
- " else:\n " ,
92
- " # If multiple versions of MSVC are installed, get the most recent one.\n " ,
93
- " cl_path = cl_paths[-1]\n " ,
94
- " vs_dir = str(cl_path.parent)\n " ,
95
- " os.environ[\" PATH\" ] += f\" {os.pathsep}{vs_dir}\"\n " ,
96
- " # The code for finding the library dirs is from\n " ,
97
- " # https://stackoverflow.com/questions/47423246/get-pythons-lib-path\n " ,
98
- " d = distutils.core.Distribution()\n " ,
99
- " b = distutils.command.build_ext.build_ext(d)\n " ,
100
- " b.finalize_options()\n " ,
101
- " os.environ[\" LIB\" ] = os.pathsep.join(b.library_dirs)\n " ,
102
- " print(f\" Added {vs_dir} to PATH\" )"
55
+ " %pip install -q \" openvino>=2024.0.0\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu\n " ,
56
+ " %pip install -q \" nncf>=2.9.0\" "
103
57
]
104
58
},
105
59
{
106
- "attachments" : {},
107
60
"cell_type" : " markdown" ,
108
61
"metadata" : {},
109
62
"source" : [
146
99
]
147
100
},
148
101
{
149
- "attachments" : {},
150
102
"cell_type" : " markdown" ,
151
103
"metadata" : {},
152
104
"source" : [
206
158
]
207
159
},
208
160
{
209
- "attachments" : {},
210
161
"cell_type" : " markdown" ,
211
162
"metadata" : {},
212
163
"source" : [
264
215
]
265
216
},
266
217
{
267
- "attachments" : {},
268
218
"cell_type" : " markdown" ,
269
219
"metadata" : {},
270
220
"source" : [
340
290
]
341
291
},
342
292
{
343
- "attachments" : {},
344
293
"cell_type" : " markdown" ,
345
294
"metadata" : {},
346
295
"source" : [
404
353
]
405
354
},
406
355
{
407
- "attachments" : {},
408
356
"cell_type" : " markdown" ,
409
357
"metadata" : {},
410
358
"source" : [
441
389
]
442
390
},
443
391
{
444
- "attachments" : {},
445
392
"cell_type" : " markdown" ,
446
393
"metadata" : {},
447
394
"source" : [
507
454
]
508
455
},
509
456
{
510
- "attachments" : {},
511
457
"cell_type" : " markdown" ,
512
458
"metadata" : {},
513
459
"source" : [
518
464
]
519
465
},
520
466
{
521
- "attachments" : {},
522
467
"cell_type" : " markdown" ,
523
468
"metadata" : {},
524
469
"source" : [
557
502
]
558
503
},
559
504
{
560
- "attachments" : {},
561
505
"cell_type" : " markdown" ,
562
506
"metadata" : {},
563
507
"source" : [
569
513
]
570
514
},
571
515
{
572
- "attachments" : {},
573
516
"cell_type" : " markdown" ,
574
517
"metadata" : {},
575
518
"source" : [
596
539
]
597
540
},
598
541
{
599
- "attachments" : {},
600
542
"cell_type" : " markdown" ,
601
543
"metadata" : {},
602
544
"source" : [
639
581
]
640
582
},
641
583
{
642
- "attachments" : {},
643
584
"cell_type" : " markdown" ,
644
585
"metadata" : {},
645
586
"source" : [
674
615
]
675
616
},
676
617
{
677
- "attachments" : {},
678
618
"cell_type" : " markdown" ,
679
619
"metadata" : {},
680
620
"source" : [
681
621
" It should be noted that the inference time for the quantized PyTorch model is longer than that of the original model, as fake quantizers are added to the model by NNCF. However, the model's performance will significantly improve when it is in the OpenVINO Intermediate Representation (IR) format."
682
622
]
683
623
},
684
624
{
685
- "attachments" : {},
686
625
"cell_type" : " markdown" ,
687
626
"metadata" : {},
688
627
"source" : [
759
698
]
760
699
},
761
700
{
762
- "attachments" : {},
763
701
"cell_type" : " markdown" ,
764
702
"metadata" : {},
765
703
"source" : [
806
744
]
807
745
},
808
746
{
809
- "attachments" : {},
810
747
"cell_type" : " markdown" ,
811
748
"metadata" : {},
812
749
"source" : [
881
818
]
882
819
},
883
820
{
884
- "attachments" : {},
885
821
"cell_type" : " markdown" ,
886
822
"metadata" : {},
887
823
"source" : [
972
908
]
973
909
},
974
910
{
975
- "attachments" : {},
976
911
"cell_type" : " markdown" ,
977
912
"metadata" : {},
978
913
"source" : [
1018
953
"provenance" : []
1019
954
},
1020
955
"kernelspec" : {
1021
- "display_name" : " Python 3" ,
956
+ "display_name" : " Python 3 (ipykernel) " ,
1022
957
"language" : " python" ,
1023
958
"name" : " python3"
1024
959
},
1032
967
"name" : " python" ,
1033
968
"nbconvert_exporter" : " python" ,
1034
969
"pygments_lexer" : " ipython3" ,
1035
- "version" : " 3.11.5 "
970
+ "version" : " 3.8.10 "
1036
971
},
1037
972
"openvino_notebooks" : {
1038
973
"imageUrl" : " " ,
1055
990
},
1056
991
"widgets" : {
1057
992
"application/vnd.jupyter.widget-state+json" : {
1058
- "state" : {
1059
- "5ba51a4155a94f2f9b2021414519d2fd" : {
1060
- "model_module" : " @jupyter-widgets/base" ,
1061
- "model_module_version" : " 2.0.0" ,
1062
- "model_name" : " LayoutModel" ,
1063
- "state" : {}
1064
- },
1065
- "88897c3f697f4cef82e9b7c3e0064fa4" : {
1066
- "model_module" : " @jupyter-widgets/controls" ,
1067
- "model_module_version" : " 2.0.0" ,
1068
- "model_name" : " DescriptionStyleModel" ,
1069
- "state" : {
1070
- "description_width" : " "
1071
- }
1072
- },
1073
- "e4be0e28604d4474ba58bb32a06e4514" : {
1074
- "model_module" : " @jupyter-widgets/controls" ,
1075
- "model_module_version" : " 2.0.0" ,
1076
- "model_name" : " DropdownModel" ,
1077
- "state" : {
1078
- "_options_labels" : [
1079
- " CPU" ,
1080
- " GPU" ,
1081
- " AUTO"
1082
- ],
1083
- "description" : " Device:" ,
1084
- "index" : 2 ,
1085
- "layout" : " IPY_MODEL_5ba51a4155a94f2f9b2021414519d2fd" ,
1086
- "style" : " IPY_MODEL_88897c3f697f4cef82e9b7c3e0064fa4"
1087
- }
1088
- }
1089
- },
993
+ "state" : {},
1090
994
"version_major" : 2 ,
1091
995
"version_minor" : 0
1092
996
}
1093
997
}
1094
998
},
1095
999
"nbformat" : 4 ,
1096
1000
"nbformat_minor" : 4
1097
- }
1001
+ }
0 commit comments