From e678798d0676ea3905a1f04657f103d0a8ffdc7b Mon Sep 17 00:00:00 2001 From: eaidova Date: Mon, 3 Feb 2025 15:38:28 +0400 Subject: [PATCH] offline experience fixes --- .../blip-visual-language-processing.ipynb | 1 + notebooks/depth-anything/depth-anything.ipynb | 16 ++++++++-------- .../instruct-pix2pix-image-editing.ipynb | 3 ++- .../optical-character-recognition.ipynb | 12 ++++++------ .../yolov11-keypoint-detection.ipynb | 3 ++- .../yolov8-object-detection.ipynb | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb b/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb index cc6c47992cb..4ef3e28f8f9 100644 --- a/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb +++ b/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb @@ -1644,6 +1644,7 @@ "\n", "comp_text_encoder = core.compile_model(TEXT_ENCODER_OV, device.value)\n", "comp_text_decoder_with_past = core.compile_model(TEXT_DECODER_OV, device.value)\n", + "comp_vision_model = core.compile_model(VISION_MODEL_OV, device.value)\n", "fp_text_decoder.forward = partial(text_decoder_forward, ov_text_decoder_with_past=comp_text_decoder_with_past)\n", "fp16_model = OVBlipModel(model.config, model.decoder_start_token_id, comp_vision_model, comp_text_encoder, fp_text_decoder)" ] diff --git a/notebooks/depth-anything/depth-anything.ipynb b/notebooks/depth-anything/depth-anything.ipynb index 46c05edda74..61ea03dcf36 100644 --- a/notebooks/depth-anything/depth-anything.ipynb +++ b/notebooks/depth-anything/depth-anything.ipynb @@ -69,13 +69,7 @@ " r = requests.get(\n", " url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/cmd_helper.py\",\n", " )\n", - " open(\"cmd_helper.py\", \"w\").write(r.text)\n", - "\n", - "if not Path(\"notebook_utils.py\").exists():\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)" + " open(\"cmd_helper.py\", \"w\").write(r.text)" ] }, { @@ -109,7 +103,13 @@ "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\"" + " %pip install -q \"gradio-imageslider<=0.0.17\" \"typing-extensions>=4.9.0\"\n", + "\n", + "if not Path(\"notebook_utils.py\").exists():\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)" ] }, { diff --git a/notebooks/instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb b/notebooks/instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb index 2bee53d26b7..32a5d4d24d9 100644 --- a/notebooks/instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb +++ b/notebooks/instruct-pix2pix-image-editing/instruct-pix2pix-image-editing.ipynb @@ -1080,12 +1080,13 @@ "source": [ "import io\n", "import requests\n", + "from diffusers.utils import load_image\n", "\n", "default_image_path = Path(\"default_image.png\")\n", "default_url = \"https://user-images.githubusercontent.com/29454499/223343459-4ac944f0-502e-4acf-9813-8e9f0abc8a16.jpg\"\n", "\n", "if not default_image_path.exists():\n", - " img = PIL.Image.open(io.BytesIO(requests.get(default_url, stream=True).raw))\n", + " img = load_image(default_url)\n", " img.save(default_image_path)\n", "\n", "default_image = PIL.Image.open(default_image_path)\n", diff --git a/notebooks/optical-character-recognition/optical-character-recognition.ipynb b/notebooks/optical-character-recognition/optical-character-recognition.ipynb index 75eda70afbe..983a1562eb1 100644 --- a/notebooks/optical-character-recognition/optical-character-recognition.ipynb +++ b/notebooks/optical-character-recognition/optical-character-recognition.ipynb @@ -94,7 +94,7 @@ " )\n", "\n", " open(\"notebook_utils.py\", \"w\").write(r.text)\n", - "from notebook_utils import load_image, device_widget\n", + "from notebook_utils import download_file, device_widget\n", "\n", "# Read more about telemetry collection at https://github.com/openvinotoolkit/openvino_notebooks?tab=readme-ov-file#-telemetry\n", "from notebook_utils import collect_telemetry\n", @@ -290,14 +290,14 @@ } ], "source": [ - "# The `image_file` variable can point to a URL or a local image.\n", - "image_url = \"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/image/intel_rnb.jpg\"\n", - "\n", "image_path = Path(\"intel_rnb.jpg\")\n", "\n", "if not image_path.exists():\n", - " image = load_image(image_url)\n", - " cv2.imwrite(str(image_path), image)\n", + " download_file(\n", + " url=\"https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/image/intel_rnb.jpg\",\n", + " filename=image_path.name,\n", + " directory=image_path.parent,\n", + " )\n", "else:\n", " image = cv2.imread(str(image_path))\n", "\n", diff --git a/notebooks/yolov11-optimization/yolov11-keypoint-detection.ipynb b/notebooks/yolov11-optimization/yolov11-keypoint-detection.ipynb index d53a21862d2..9fbde2decbc 100644 --- a/notebooks/yolov11-optimization/yolov11-keypoint-detection.ipynb +++ b/notebooks/yolov11-optimization/yolov11-keypoint-detection.ipynb @@ -117,12 +117,13 @@ "# Fetch `notebook_utils` module\n", "import requests\n", "\n", - "if Path(\"notebook_utils.py\").exists():\n", + "if not Path(\"notebook_utils.py\").exists():\n", " r = requests.get(\n", " url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n", " )\n", "\n", " open(\"notebook_utils.py\", \"w\").write(r.text)\n", + "\n", "from notebook_utils import download_file, VideoPlayer, device_widget\n", "\n", "# Read more about telemetry collection at https://github.com/openvinotoolkit/openvino_notebooks?tab=readme-ov-file#-telemetry\n", diff --git a/notebooks/yolov8-optimization/yolov8-object-detection.ipynb b/notebooks/yolov8-optimization/yolov8-object-detection.ipynb index 1bcd46d016e..e7fa6ff2aec 100644 --- a/notebooks/yolov8-optimization/yolov8-object-detection.ipynb +++ b/notebooks/yolov8-optimization/yolov8-object-detection.ipynb @@ -132,7 +132,7 @@ "# Fetch `notebook_utils` module\n", "import requests\n", "\n", - "if not Path(\"notebook_utils.py\").exists()\n", + "if not Path(\"notebook_utils.py\").exists():\n", " r = requests.get(\n", " url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n", " )\n",