Skip to content

Commit

Permalink
offline experience fixes (#2711)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Feb 3, 2025
1 parent 9f4fefd commit 05bf241
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion notebooks/bark-text-to-audio/bark-text-to-audio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"source": [
"text_use_small = True\n",
"\n",
"text_encoder = load_model(model_type=\"text\", use_gpu=False, use_small=text_use_small, force_reload=False)\n",
"text_encoder = load_model(model_type=\"text\", use_gpu=False, use_small=text_use_small, force_reload=False, weights_only=False)\n",
"\n",
"text_encoder_model = text_encoder[\"model\"]\n",
"tokenizer = text_encoder[\"tokenizer\"]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down
16 changes: 8 additions & 8 deletions notebooks/depth-anything/depth-anything.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions notebooks/llm-agent-react/llm-agent-react-langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@
"import openvino.properties.hint as hints\n",
"import openvino.properties.streams as streams\n",
"\n",
"import torch\n",
"\n",
"if hasattr(torch, \"mps\") and torch.mps.is_available:\n",
" torch.mps.is_available = lambda: False\n",
"\n",
"\n",
"class StopSequenceCriteria(StoppingCriteria):\n",
" \"\"\"\n",
Expand Down
5 changes: 5 additions & 0 deletions notebooks/multimodal-rag/multimodal-rag-llamaindex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"\n",
"if hasattr(torch, \"mps\") and torch.mps.is_available:\n",
" torch.mps.is_available = lambda: False\n",
"\n",
"from llama_index.core.indices import MultiModalVectorStoreIndex\n",
"from llama_index.vector_stores.qdrant import QdrantVectorStore\n",
"from llama_index.core import StorageContext, Settings\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/paddle-ocr-webcam/pre_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def draw_ocr_box_txt(image, boxes, txts, scores=None, drop_score=0.5, font_path=
try:
char_size = font.getbox(c)
y_idx = -1
except AttributeError:
except Exception:
char_size = font.getsize(c)
y_idx = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"\n",
"%pip install -q \"openvino>=2023.2.0\"\n",
"clone_repo(\"https://github.com/svc-develop-team/so-vits-svc\", revision=\"4.1-Stable\", add_to_sys_path=False)\n",
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu tqdm librosa \"torch>=2.1.0\" \"torchaudio>=2.1.0\" faiss-cpu \"gradio>=4.19\" \"numpy>=1.23.5\" praat-parselmouth"
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu tqdm librosa \"torch>=2.1.0,<2.6.0\" \"torchaudio>=2.1.0,<2.6.0\" faiss-cpu \"gradio>=4.19\" \"numpy>=1.23.5\" praat-parselmouth"
]
},
{
Expand Down
7 changes: 5 additions & 2 deletions notebooks/whisper-asr-genai/whisper-asr-genai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
"source": [
"from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq, pipeline\n",
"from transformers.utils import logging\n",
"import torch\n",
"\n",
"processor = AutoProcessor.from_pretrained(model_id.value)\n",
"\n",
Expand All @@ -253,7 +254,7 @@
" model=pt_model,\n",
" tokenizer=processor.tokenizer,\n",
" feature_extractor=processor.feature_extractor,\n",
" device=\"cpu\",\n",
" device=torch.device(\"cpu\"),\n",
")"
]
},
Expand Down Expand Up @@ -1017,7 +1018,9 @@
" model=ov_model,\n",
" chunk_length_s=30,\n",
" tokenizer=ov_processor.tokenizer,\n",
" feature_extractor=ov_processor.feature_extractor)\n",
" feature_extractor=ov_processor.feature_extractor,\n",
" device=torch.device(\"cpu\")\n",
" )\n",
" try:\n",
" calibration_dataset = dataset = load_dataset(\"openslr/librispeech_asr\", \"clean\", split=\"validation\", streaming=True, trust_remote_code=True)\n",
" for sample in tqdm(islice(calibration_dataset, calibration_dataset_size), desc=\"Collecting calibration data\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
" model=ov_model,\n",
" chunk_length_s=30,\n",
" tokenizer=processor.tokenizer,\n",
" feature_extractor=processor.feature_extractor)\n",
" feature_extractor=processor.feature_extractor, devide=torch.device(\"cpu\"))\n",
" try:\n",
" calibration_dataset = dataset = load_dataset(\"openslr/librispeech_asr\", \"clean\", split=\"validation\", streaming=True, trust_remote_code=True)\n",
" for sample in tqdm(islice(calibration_dataset, calibration_dataset_size), desc=\"Collecting calibration data\",\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/yolov10-optimization/yolov10-optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"%pip install -q \"nncf>=2.11.0\"\n",
"%pip install -Uq \"openvino>=2024.3.0\"\n",
"%pip install -q \"git+https://github.com/THU-MIG/yolov10.git\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q \"torch>=2.1\" \"torchvision>=0.16\" tqdm opencv-python \"gradio>=4.19\" \"matplotlib>=3.9\" --extra-index-url https://download.pytorch.org/whl/cpu"
"%pip install -q \"torch>=2.1,<2.6\" \"torchvision>=0.16\" tqdm opencv-python \"gradio>=4.19\" \"matplotlib>=3.9\" --extra-index-url https://download.pytorch.org/whl/cpu"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/yolov9-optimization/yolov9-optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install -q \"openvino>=2023.3.0\" \"nncf>=2.8.1\" \"opencv-python\" \"matplotlib>=3.4\" \"seaborn\" \"pandas\" \"scikit-learn\" \"torch\" \"torchvision\" \"tqdm\" --extra-index-url https://download.pytorch.org/whl/cpu"
"%pip install -q \"openvino>=2023.3.0\" \"nncf>=2.8.1\" \"opencv-python\" \"matplotlib>=3.4\" \"seaborn\" \"pandas\" \"scikit-learn\" \"torch<2.6.0\" \"torchvision\" \"tqdm\" --extra-index-url https://download.pytorch.org/whl/cpu"
]
},
{
Expand Down

0 comments on commit 05bf241

Please sign in to comment.