Skip to content

Commit

Permalink
replace optimum-cli method
Browse files Browse the repository at this point in the history
  • Loading branch information
openvino-dev-samples committed Nov 22, 2024
2 parents e5fee63 + 88f8103 commit e74426c
Show file tree
Hide file tree
Showing 47 changed files with 1,421 additions and 5,520 deletions.
7 changes: 0 additions & 7 deletions .ci/skipped_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,6 @@
- ubuntu-20.04
- ubuntu-22.04
- windows-2019
- notebook: notebooks/internvl2/internvl2.ipynb
skips:
- os:
- macos-12
- ubuntu-20.04
- ubuntu-22.04
- windows-2019
- notebook: notebooks/qwen2-vl/qwen2-vl.ipynb
skips:
- os:
Expand Down
10 changes: 8 additions & 2 deletions .ci/spellcheck/.pyspelling.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ embeddings
EnCodec
encodec
english
ENLSP
enum
et
Evol
Expand All @@ -259,6 +260,7 @@ Explainer
facto
fastcomposer
FastComposer
FastDraft
FastSAM
FC
feedforward
Expand Down Expand Up @@ -417,6 +419,7 @@ Kosaraju
kosmos
Kosmos
KOSMOS
Kozlov
KServe
Kubernetes
Kupyn
Expand Down Expand Up @@ -472,11 +475,12 @@ Lyth
MaaS
macOS
Magika
masklet
Mahalanobis
Mamou
Mapillary
Markovian
Martyniuk
masklet
maskrcnn
MaterialMLP
MaterialNet
Expand Down Expand Up @@ -553,6 +557,7 @@ NEOX
NER
NETP
Netron
NeurIPS
NeuSpell
NeXT
NLP
Expand Down Expand Up @@ -1019,6 +1024,7 @@ Würstchen
XAI
XCode
Xeon
xformers
xl
xt
xvector
Expand All @@ -1030,10 +1036,10 @@ YOLOv
yolov
Youri
youri
Zafrir
ZavyChromaXL
Zongyuan
ZeroScope
zeroscope
Zhipu
zh
xformers
2 changes: 1 addition & 1 deletion .docker/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ notebook = "<7.0.0"
numpy = ">=1.21.0"
onnx = ">=1.11.0"
opencv-python = "*"
openvino-dev = {version = "==2024.4.0"}
openvino = {version = "==2024.5.0"}
openvino-telemetry = "==2023.2.1"
ovmsclient = "*"
Pillow = ">=8.3.2"
Expand Down
12 changes: 3 additions & 9 deletions .docker/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ OpenVINO Notebooks require Python and Git. To get started, select the guide for

Explore Jupyter notebooks using this [page](https://openvinotoolkit.github.io/openvino_notebooks/), select one related to your needs or give them all a try. Good Luck!

**NOTE: The main branch of this repository was updated to support the new OpenVINO 2024.4 release.** To upgrade to the new release version, please run `pip install --upgrade -r requirements.txt` in your `openvino_env` virtual environment. If you need to install for the first time, see the [Installation Guide](#-installation-guide) section below. If you wish to use the previous release version of OpenVINO, please checkout the [2024.3 branch](https://github.com/openvinotoolkit/openvino_notebooks/tree/2024.2). If you wish to use the previous Long Term Support (LTS) version of OpenVINO check out the [2023.3 branch](https://github.com/openvinotoolkit/openvino_notebooks/tree/2023.3).
**NOTE: The main branch of this repository was updated to support the new OpenVINO 2024.5 release.** To upgrade to the new release version, please run `pip install --upgrade -r requirements.txt` in your `openvino_env` virtual environment. If you need to install for the first time, see the [Installation Guide](#-installation-guide) section below. If you wish to use the previous release version of OpenVINO, please checkout the [2024.4 branch](https://github.com/openvinotoolkit/openvino_notebooks/tree/2024.4). If you wish to use the previous Long Term Support (LTS) version of OpenVINO check out the [2023.3 branch](https://github.com/openvinotoolkit/openvino_notebooks/tree/2023.3).

If you need help, please start a GitHub [Discussion](https://github.com/openvinotoolkit/openvino_notebooks/discussions).

Expand Down
56 changes: 7 additions & 49 deletions notebooks/3D-pose-estimation-webcam/3D-pose-estimation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,58 +77,16 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "b84c1f5e-502b-4037-b871-9f84b4e8cef0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu\n",
"Requirement already satisfied: pythreejs in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (2.4.2)\n",
"Requirement already satisfied: openvino>=2024.4.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (2024.4.0)\n",
"Requirement already satisfied: opencv-python in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (4.10.0.84)\n",
"Requirement already satisfied: torch in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (2.5.1+cpu)\n",
"Requirement already satisfied: tqdm in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (4.67.0)\n",
"Requirement already satisfied: ipywidgets>=7.2.1 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from pythreejs) (8.1.5)\n",
"Requirement already satisfied: ipydatawidgets>=1.1.1 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from pythreejs) (4.3.5)\n",
"Requirement already satisfied: numpy in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from pythreejs) (1.26.4)\n",
"Requirement already satisfied: traitlets in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from pythreejs) (5.14.3)\n",
"Requirement already satisfied: openvino-telemetry>=2023.2.1 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from openvino>=2024.4.0) (2024.1.0)\n",
"Requirement already satisfied: packaging in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from openvino>=2024.4.0) (24.2)\n",
"Requirement already satisfied: filelock in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (3.16.1)\n",
"Requirement already satisfied: typing-extensions>=4.8.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (4.12.2)\n",
"Requirement already satisfied: networkx in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (3.3)\n",
"Requirement already satisfied: jinja2 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (3.1.4)\n",
"Requirement already satisfied: fsspec in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (2024.9.0)\n",
"Requirement already satisfied: setuptools in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (75.5.0)\n",
"Requirement already satisfied: sympy==1.13.1 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from torch) (1.13.1)\n",
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from sympy==1.13.1->torch) (1.3.0)\n",
"Requirement already satisfied: colorama in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from tqdm) (0.4.6)\n",
"Requirement already satisfied: traittypes>=0.2.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipydatawidgets>=1.1.1->pythreejs) (0.2.1)\n",
"Requirement already satisfied: comm>=0.1.3 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipywidgets>=7.2.1->pythreejs) (0.2.2)\n",
"Requirement already satisfied: ipython>=6.1.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipywidgets>=7.2.1->pythreejs) (8.29.0)\n",
"Requirement already satisfied: widgetsnbextension~=4.0.12 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipywidgets>=7.2.1->pythreejs) (4.0.13)\n",
"Requirement already satisfied: jupyterlab-widgets~=3.0.12 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipywidgets>=7.2.1->pythreejs) (3.0.13)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from jinja2->torch) (2.1.5)\n",
"Requirement already satisfied: decorator in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (5.1.1)\n",
"Requirement already satisfied: jedi>=0.16 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.19.2)\n",
"Requirement already satisfied: matplotlib-inline in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.1.7)\n",
"Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (3.0.48)\n",
"Requirement already satisfied: pygments>=2.4.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.18.0)\n",
"Requirement already satisfied: stack-data in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.6.3)\n",
"Requirement already satisfied: parso<0.9.0,>=0.8.4 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.8.4)\n",
"Requirement already satisfied: wcwidth in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.13)\n",
"Requirement already satisfied: executing>=1.2.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.1.0)\n",
"Requirement already satisfied: asttokens>=2.1.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.4.1)\n",
"Requirement already satisfied: pure-eval in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.3)\n",
"Requirement already satisfied: six>=1.12.0 in c:\\users\\akochin\\openvino_notebooks\\.venv\\lib\\site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (1.16.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"import platform\n",
"\n",
"if platform.system() == \"Darwin\":\n",
" %pip install -q \"numpy<2.0.0\"\n",
"\n",
"%pip install pythreejs \"openvino>=2024.4.0\" \"opencv-python\" \"torch\" \"tqdm\" --extra-index-url https://download.pytorch.org/whl/cpu"
]
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- [Image generation with Stable Diffusion XL and OpenVINO](./stable-diffusion-xl/stable-diffusion-xl.ipynb)
- [High-resolution image generation with Segmind-VegaRT and OpenVINO](./stable-diffusion-xl/segmind-vegart.ipynb)
- [Image generation with Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3.ipynb)
- [Image generation with Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3-torch-fx.ipynb)
- [Image generation with Torch.FX Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3-torch-fx.ipynb)
- [Text-to-Image Generation with Stable Diffusion v2 and OpenVINO™](./stable-diffusion-v2/stable-diffusion-v2-text-to-image.ipynb)
- [Stable Diffusion Text-to-Image Demo](./stable-diffusion-v2/stable-diffusion-v2-text-to-image-demo.ipynb)
- [Stable Diffusion v2.1 using Optimum-Intel OpenVINO and multiple Intel Hardware](./stable-diffusion-v2/stable-diffusion-v2-optimum-demo.ipynb)
Expand Down Expand Up @@ -195,7 +195,7 @@
- [Image generation with Stable Diffusion XL and OpenVINO](./stable-diffusion-xl/stable-diffusion-xl.ipynb)
- [High-resolution image generation with Segmind-VegaRT and OpenVINO](./stable-diffusion-xl/segmind-vegart.ipynb)
- [Image generation with Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3.ipynb)
- [Image generation with Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3-torch-fx.ipynb)
- [Image generation with Torch.FX Stable Diffusion v3 and OpenVINO](./stable-diffusion-v3/stable-diffusion-v3-torch-fx.ipynb)
- [Text-to-Image Generation with Stable Diffusion v2 and OpenVINO™](./stable-diffusion-v2/stable-diffusion-v2-text-to-image.ipynb)
- [Stable Diffusion Text-to-Image Demo](./stable-diffusion-v2/stable-diffusion-v2-text-to-image-demo.ipynb)
- [Stable Diffusion v2.1 using Optimum-Intel OpenVINO and multiple Intel Hardware](./stable-diffusion-v2/stable-diffusion-v2-optimum-demo.ipynb)
Expand All @@ -206,7 +206,7 @@
- [Image Generation with Stable Diffusion and IP-Adapter](./stable-diffusion-ip-adapter/stable-diffusion-ip-adapter.ipynb)
- [Image generation with Stable Cascade and OpenVINO](./stable-cascade-image-generation/stable-cascade-image-generation.ipynb)
- [Sound Generation with Stable Audio Open and OpenVINO™](./stable-audio/stable-audio.ipynb)
- [Text Generation via Speculative Decoding and OpenVINO™](./speculative-sampling/speculative-sampling.ipynb)
- [Text Generation via Speculative Decoding using FastDraft and OpenVINO™](./speculative-sampling/speculative-sampling.ipynb)
- [Sound Generation with AudioLDM2 and OpenVINO™](./sound-generation-audioldm2/sound-generation-audioldm2.ipynb)
- [SoftVC VITS Singing Voice Conversion and OpenVINO™](./softvc-voice-conversion/softvc-voice-conversion.ipynb)
- [One Step Sketch to Image translation with pix2pix-turbo and OpenVINO](./sketch-to-image-pix2pix-turbo/sketch-to-image-pix2pix-turbo.ipynb)
Expand Down
10 changes: 6 additions & 4 deletions notebooks/depth-anything/depth-anything-v2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
"%pip install -q \"typing-extensions>=4.9.0\" eval-type-backport \"gradio>=4.19\" gradio_imageslider\n",
"%pip install -q torch torchvision \"opencv-python\" huggingface_hub --extra-index-url https://download.pytorch.org/whl/cpu\n",
"\n",
"if platform.system() == \"Darwin\":\n",
" %pip install -q \"numpy<2.0.0\"\n",
"if platform.python_version_tuple()[1] in [\"8\", \"9\"]:\n",
" %pip install -q \"gradio-imageslider<=0.0.17\" \"typing-extensions>=4.9.0\""
]
Expand Down Expand Up @@ -1478,14 +1480,14 @@
" depth = predict_depth(compiled_model, image)\n",
" depth = cv2.resize(depth[0], (w, h), interpolation=cv2.INTER_LINEAR)\n",
"\n",
" raw_depth = Image.fromarray(depth.astype(\"uint16\"))\n",
" tmp = tempfile.NamedTemporaryFile(suffix=\".png\", delete=False)\n",
" raw_depth.save(tmp.name)\n",
"\n",
" depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0\n",
" depth = depth.astype(np.uint8)\n",
" colored_depth = cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)[:, :, ::-1]\n",
"\n",
" colored_depth_img = Image.fromarray(colored_depth)\n",
" tmp = tempfile.NamedTemporaryFile(suffix=\".png\", delete=False)\n",
" colored_depth_img.save(tmp.name)\n",
"\n",
" return [(original_image, colored_depth), tmp.name]"
]
},
Expand Down
10 changes: 6 additions & 4 deletions notebooks/depth-anything/depth-anything.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
"%pip install -q \"typing-extensions>=4.9.0\" eval-type-backport \"gradio>=4.19\" \"matplotlib>=3.4\"\n",
"%pip install -q torch torchvision \"opencv-python\" huggingface_hub --extra-index-url https://download.pytorch.org/whl/cpu\n",
"\n",
"if platform.system() == \"Darwin\":\n",
" %pip install -q \"numpy<2.0.0\"\n",
"if platform.python_version_tuple()[1] in [\"8\", \"9\"]:\n",
" %pip install -q \"gradio-imageslider<=0.0.17\" \"typing-extensions>=4.9.0\""
]
Expand Down Expand Up @@ -1270,14 +1272,14 @@
" depth = predict_depth(compiled_model, image)\n",
" depth = cv2.resize(depth[0], (w, h), interpolation=cv2.INTER_LINEAR)\n",
"\n",
" raw_depth = Image.fromarray(depth.astype(\"uint16\"))\n",
" tmp = tempfile.NamedTemporaryFile(suffix=\".png\", delete=False)\n",
" raw_depth.save(tmp.name)\n",
"\n",
" depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0\n",
" depth = depth.astype(np.uint8)\n",
" colored_depth = cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)[:, :, ::-1]\n",
"\n",
" colored_depth_img = Image.fromarray(colored_depth)\n",
" tmp = tempfile.NamedTemporaryFile(suffix=\".png\", delete=False)\n",
" colored_depth_img.save(tmp.name)\n",
"\n",
" return [(original_image, colored_depth), tmp.name]"
]
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/depth-anything/gradio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def make_demo(fn: Callable, examples_dir: str):
with gr.Row():
input_image = gr.Image(label="Input Image", type="numpy", elem_id="img-display-input")
depth_image_slider = ImageSlider(label="Depth Map with Slider View", elem_id="img-display-output", position=0)
raw_file = gr.File(label="16-bit raw depth (can be considered as disparity)")
depth_image_file = gr.File(label="Depth Image")
submit = gr.Button("Submit")

submit.click(fn=fn, inputs=[input_image], outputs=[depth_image_slider, raw_file])
submit.click(fn=fn, inputs=[input_image], outputs=[depth_image_slider, depth_image_file])

if not Path(examples_dir).exists():
gr.Error(f"Examples directory {examples_dir} does not exist.")
Expand All @@ -37,7 +37,7 @@ def make_demo(fn: Callable, examples_dir: str):
examples = gr.Examples(
examples=example_files,
inputs=[input_image],
outputs=[depth_image_slider, raw_file],
outputs=[depth_image_slider, depth_image_file],
fn=fn,
cache_examples=False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "b3ce0481-d7de-4d37-9414-c72dc6488f8e",
"metadata": {},
"outputs": [
Expand All @@ -155,7 +155,7 @@
"from huggingface_hub import hf_hub_download\n",
"from omegaconf import OmegaConf\n",
"\n",
"from dynamicrafter.utils.utils import instantiate_from_config\n",
"from utils.utils import instantiate_from_config\n",
"\n",
"\n",
"def load_model_checkpoint(model, ckpt):\n",
Expand Down Expand Up @@ -287,7 +287,7 @@
"metadata": {},
"outputs": [],
"source": [
"from dynamicrafter.lvdm.modules.encoders.condition import FrozenOpenCLIPEmbedder\n",
"from lvdm.modules.encoders.condition import FrozenOpenCLIPEmbedder\n",
"\n",
"MODEL_DIR = Path(\"models\")\n",
"\n",
Expand Down
Loading

0 comments on commit e74426c

Please sign in to comment.