Skip to content

Commit

Permalink
Finalize the standalone approach for the notebooks (#1942)
Browse files Browse the repository at this point in the history
  • Loading branch information
yatarkan and github-actions[bot] authored Apr 19, 2024
1 parent 4fc018f commit 0382dbe
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 631 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
}
],
"source": [
"from pathlib import Path\n",
"\n",
"if not Path(\"./utils.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/blip-visual-language-processing/utils.py\")\n",
"from utils import visualize_results\n",
"\n",
"fig = visualize_results(raw_image, answer, question)"
Expand Down Expand Up @@ -616,6 +620,8 @@
},
"outputs": [],
"source": [
"if not Path(\"./blip_model.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/blip-visual-language-processing/blip_model.py\")\n",
"from blip_model import OVBlipModel\n",
"\n",
"ov_model = OVBlipModel(model.config, model.decoder_start_token_id, ov_vision_model, ov_text_encoder, text_decoder)\n",
Expand Down
10 changes: 6 additions & 4 deletions notebooks/ct-segmentation-quantize/ct-scan-live-inference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@
"from monai.transforms import LoadImage\n",
"import openvino as ov\n",
"\n",
"from custom_segmentation import SegmentationModel\n",
"\n",
"# Fetch `notebook_utils` module\n",
"import requests\n",
"\n",
"# Fetch `notebook_utils` module\n",
"r = requests.get(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file\n",
"\n",
"if not Path(\"./custom_segmentation.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/ct-segmentation-quantize/custom_segmentation.py\")\n",
"from custom_segmentation import SegmentationModel"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,23 @@
"from monai.transforms import LoadImage\n",
"from nncf.common.logging.logger import set_log_level\n",
"from torchmetrics import F1Score as F1\n",
"import requests\n",
"\n",
"set_log_level(logging.ERROR) # Disables all NNCF info and warning messages\n",
"\n",
"from custom_segmentation import SegmentationModel\n",
"from async_pipeline import show_live_inference\n",
"set_log_level(logging.ERROR) # Disables all NNCF info and warning messages\n",
"\n",
"# Fetch `notebook_utils` module\n",
"import requests\n",
"\n",
"r = requests.get(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\")\n",
"from notebook_utils import download_file"
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"\n",
"if not Path(\"./custom_segmentation.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/ct-segmentation-quantize/custom_segmentation.py\")\n",
"from custom_segmentation import SegmentationModel\n",
"\n",
"if not Path(\"./async_pipeline.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/ct-segmentation-quantize/async_pipeline.py\")\n",
"from async_pipeline import show_live_inference"
]
},
{
Expand Down
14 changes: 14 additions & 0 deletions notebooks/deepfloyd-if/deep-floyd-if-convert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@
"from diffusers import DiffusionPipeline\n",
"import openvino as ov\n",
"import torch\n",
"\n",
"# Fetch `notebook_utils` module\n",
"import requests\n",
"\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",
"from notebook_utils import download_file\n",
"\n",
"if not Path(\"./utils.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/deepfloyd-if/utils.py\")\n",
"\n",
"from utils import (\n",
" TextEncoder,\n",
" UnetFirstStage,\n",
Expand Down
13 changes: 13 additions & 0 deletions notebooks/deepfloyd-if/deep-floyd-if-optimize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@
"from pathlib import Path\n",
"from typing import Any, List\n",
"\n",
"# Fetch `notebook_utils` module\n",
"import requests\n",
"\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",
"from notebook_utils import download_file\n",
"\n",
"if not Path(\"./utils.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/deepfloyd-if/utils.py\")\n",
"\n",
"from utils import TextEncoder, UnetFirstStage, UnetSecondStage\n",
"\n",
"checkpoint_variant = \"fp16\"\n",
Expand Down
13 changes: 7 additions & 6 deletions notebooks/deepfloyd-if/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from pathlib import Path
from PIL import Image

# Fetch `notebook_utils` module
import requests
if not Path("./notebook_utils.py").exists():
# Fetch `notebook_utils` module
import requests

r = requests.get(
url="https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py",
)
r = requests.get(
url="https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py",
)

open("notebook_utils.py", "w").write(r.text)
open("notebook_utils.py", "w").write(r.text)
from notebook_utils import download_file


Expand Down
12 changes: 12 additions & 0 deletions notebooks/llm-question-answering/llm-question-answering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import requests\n",
"\n",
"# Fetch `notebook_utils` module\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)\n",
"from notebook_utils import download_file\n",
"\n",
"if not Path(\"./config.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/llm-question-answering/config.py\")\n",
"from config import SUPPORTED_LLM_MODELS\n",
"import ipywidgets as widgets"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
"import openvino as ov\n",
"import numpy as np\n",
"from pathlib import Path\n",
"import requests\n",
"\n",
"# Fetch `notebook_utils` module\n",
"r = requests.get(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"\n",
"IMAGE_WIDTH = 512\n",
"IMAGE_HEIGHT = 512\n",
Expand Down Expand Up @@ -296,11 +302,16 @@
"import tf_keras as keras\n",
"import numpy as np\n",
"import tensorflow as tf\n",
"from pathlib import Path\n",
"\n",
"from constants import UNCONDITIONAL_TOKENS, ALPHAS_CUMPROD\n",
"from keras_cv.models.stable_diffusion import SimpleTokenizer\n",
"\n",
"\n",
"if not Path(\"./constants.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/stable-diffusion-keras-cv/constants.py\")\n",
"from constants import UNCONDITIONAL_TOKENS, ALPHAS_CUMPROD\n",
"\n",
"\n",
"class StableDiffusion:\n",
" def __init__(self, text_encoder, diffusion_model, decoder):\n",
" # UNet requires multiples of 2**7 = 128\n",
Expand Down
Loading

0 comments on commit 0382dbe

Please sign in to comment.