From 3579c08ce0fdb5862cd8836076f3d571356dc0d2 Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Thu, 16 Jan 2025 23:38:02 +0400 Subject: [PATCH] fix standalone execution text2image genai (#2665) --- .../text-to-image-genai.ipynb | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/notebooks/text-to-image-genai/text-to-image-genai.ipynb b/notebooks/text-to-image-genai/text-to-image-genai.ipynb index d37df1eb46e..5d0f204f131 100644 --- a/notebooks/text-to-image-genai/text-to-image-genai.ipynb +++ b/notebooks/text-to-image-genai/text-to-image-genai.ipynb @@ -56,6 +56,7 @@ "source": [ "import platform\n", "import requests\n", + "from pathlib import Path\n", "\n", "\n", "%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\"\n", @@ -65,15 +66,19 @@ "if platform.system() == \"Darwin\":\n", " %pip install -q \"numpy<2.0.0\"\n", "\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", "\n", - "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)" + "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)\n", + "\n", + "\n", + "if not Path(\"cmd_helper.py\").exists():\n", + " 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)" ] }, { @@ -357,6 +362,19 @@ "[back to top ⬆️](#Table-of-contents:)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "175ad576", + "metadata": {}, + "outputs": [], + "source": [ + "if not Path(\"gradio_helper.py\").exists():\n", + " r = requests.get(\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/text-to-image-genai/gradio_helper.py\")\n", + " with open(\"gradio_helper.py\", \"w\") as f:\n", + " f.write(r.text)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -402,7 +420,8 @@ "tags": { "categories": [ "Model Demos", - "AI Trends" + "AI Trends", + "API Overview" ], "libraries": [], "other": [