diff --git a/.ci/patch_notebooks.py b/.ci/patch_notebooks.py index f9dbd877ddb..900edd0e9c2 100644 --- a/.ci/patch_notebooks.py +++ b/.ci/patch_notebooks.py @@ -31,9 +31,13 @@ def disable_skip_ext(nb, notebook_path, test_device=""): skip_for_device = None if test_device else False for cell in nb["cells"]: if test_device is not None and skip_for_device is None: - if 'skip_for_device = "{}" in device.value'.format(test_device.upper()) in cell["source"] and ( - "to_quantize = widgets.Checkbox(value=not skip_for_device" in cell["source"] - or "to_quantize = quantization_widget(not skip_for_device" in cell["source"] + if ( + 'skip_for_device = "{}" in device.value'.format(test_device.upper()) in cell["source"] + and ( + "to_quantize = widgets.Checkbox(value=not skip_for_device" in cell["source"] + or "to_quantize = quantization_widget(not skip_for_device" in cell["source"] + ) + or ("to_quantize = quantization_widget(False" in cell["source"]) ): skip_for_device = True @@ -152,7 +156,11 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False): if test_device and (DEVICE_WIDGET in cell["source"] or DEVICE_WIDGET_NEW in cell["source"]): device_found = True if not DEVICE_WIDGET_NEW in cell["source"]: - cell["source"] = re.sub(r"value=.*,", f"value='{test_device.upper()}',", cell["source"]) + cell["source"] = re.sub( + r"value=.*,", + f"value='{test_device.upper()}',", + cell["source"], + ) cell["source"] = re.sub( r"options=", f"options=['{test_device.upper()}'] + ", @@ -161,7 +169,9 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False): print(f"Replaced testing device to {test_device}") else: cell["source"] = re.sub( - r"device_widget\(.*\)", f"device_widget(default='{test_device.upper()}', added=['{test_device.upper()}'])", cell["source"] + r"device_widget\(.*\)", + f"device_widget(default='{test_device.upper()}', added=['{test_device.upper()}'])", + cell["source"], ) replace_dict = cell.get("metadata", {}).get("test_replace") if replace_dict is not None: diff --git a/.ci/skipped_notebooks.yml b/.ci/skipped_notebooks.yml index 07f0206203b..8690999b729 100644 --- a/.ci/skipped_notebooks.yml +++ b/.ci/skipped_notebooks.yml @@ -594,6 +594,7 @@ - '3.9' - os: - macos-12 + - windows-2019 - notebook: notebooks/segment-anything/segment-anything-2-video.ipynb skips: - python: @@ -601,3 +602,4 @@ - '3.9' - os: - macos-12 + - windows-2019 diff --git a/notebooks/segment-anything/segment-anything-2-image.ipynb b/notebooks/segment-anything/segment-anything-2-image.ipynb index fe8ec5ca009..836da3c0b82 100644 --- a/notebooks/segment-anything/segment-anything-2-image.ipynb +++ b/notebooks/segment-anything/segment-anything-2-image.ipynb @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "662e0f0d", "metadata": {}, "outputs": [], @@ -160,14 +160,17 @@ ], "source": [ "import sys\n", + "import os\n", "\n", "sam2_dir = Path(\"segment-anything-2\")\n", "\n", "if not sam2_dir.exists():\n", - " !git clone https://github.com/facebookresearch/segment-anything-2.git\n", + " exit_code = os.system(\"git clone https://github.com/facebookresearch/segment-anything-2.git\")\n", + " if exit_code != 0:\n", + " raise Exception(\"Failed to clone the repository!\")\n", "\n", "# append to sys.path so that modules from the repo could be imported\n", - "sys.path.append(str(sam2_dir))\n", + "sys.path.insert(0, str(sam2_dir.resolve()))\n", "\n", "%env SAM2_BUILD_CUDA=0" ] @@ -1442,8 +1445,7 @@ "source": [ "from notebook_utils import quantization_widget\n", "\n", - "skip_for_device = \"CPU\" in device.value\n", - "to_quantize = quantization_widget(not skip_for_device)\n", + "to_quantize = quantization_widget(False)\n", "to_quantize" ] }, diff --git a/notebooks/segment-anything/segment-anything-2-video.ipynb b/notebooks/segment-anything/segment-anything-2-video.ipynb index f916cbf211e..c5941ba85de 100644 --- a/notebooks/segment-anything/segment-anything-2-video.ipynb +++ b/notebooks/segment-anything/segment-anything-2-video.ipynb @@ -152,18 +152,29 @@ ], "source": [ "import sys\n", + "import os\n", "\n", "sam2_dir = Path(\"segment-anything-2\")\n", "\n", "if not sam2_dir.exists():\n", - " !git clone https://github.com/facebookresearch/segment-anything-2.git\n", + " exit_code = os.system(\"git clone https://github.com/facebookresearch/segment-anything-2.git\")\n", + " if exit_code != 0:\n", + " raise Exception(\"Failed to clone the repository!\")\n", "\n", "# append to sys.path so that modules from the repo could be imported\n", - "sys.path.append(str(sam2_dir))\n", + "sys.path.insert(0, str(sam2_dir.resolve()))\n", "\n", "%env SAM2_BUILD_CUDA=0" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "feea9e6b", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 4,