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 12aa99790d3..4042fbea76f 100644 --- a/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb +++ b/notebooks/blip-visual-language-processing/blip-visual-language-processing.ipynb @@ -605,6 +605,36 @@ "text_decoder.forward = partial(text_decoder_forward, ov_text_decoder_with_past=ov_text_decoder_with_past)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a3b4c12-d8e9-4f01-a2b3-c4d5e6f7a8b9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "\n", + "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\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "01ba0c67-cc02-4781-bb3a-472146362a7a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "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", + "out = ov_model.generate_answer(**inputs, max_length=20)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -618,18 +648,14 @@ { "cell_type": "code", "execution_count": null, - "id": "01ba0c67-cc02-4781-bb3a-472146362a7a", - "metadata": { - "tags": [] - }, + "id": "fd5bfc87", + "metadata": {}, "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", + "from functools import partial\n", + "from blip_model import text_decoder_forward\n", "\n", - "ov_model = OVBlipModel(model.config, model.decoder_start_token_id, ov_vision_model, ov_text_encoder, text_decoder)\n", - "out = ov_model.generate_answer(**inputs, max_length=20)" + "text_decoder.forward = partial(text_decoder_forward, ov_text_decoder_with_past=ov_text_decoder_with_past)" ] }, {