From 76121acdecd958fc4144b8d0c6280c5e180a8a14 Mon Sep 17 00:00:00 2001 From: Ilya Trushkin Date: Tue, 9 Jan 2024 17:24:07 +0200 Subject: [PATCH] Fix Gradio deprecated functionality in 272-paint-by-example (#1598) * Fix gradio deprecated functionality Signed-off-by: Ilya Trushkin * Resolve pip conflicts Signed-off-by: Ilya Trushkin --------- Signed-off-by: Ilya Trushkin --- .../237-segment-anything.ipynb | 2 +- .../261-fast-segment-anything.ipynb | 2 +- .../272-paint-by-example.ipynb | 52 +++++++++---------- .../274-efficient-sam/274-efficient-sam.ipynb | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/notebooks/237-segment-anything/237-segment-anything.ipynb b/notebooks/237-segment-anything/237-segment-anything.ipynb index 38e567481de..93c5e5df9a1 100644 --- a/notebooks/237-segment-anything/237-segment-anything.ipynb +++ b/notebooks/237-segment-anything/237-segment-anything.ipynb @@ -79,7 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "%pip install -q \"segment_anything\" \"gradio>=3.25,<4.9\" \"openvino>=2023.1.0\" \"nncf>=2.5.0\" \"torch>=2.1\" \"torchvision>=0.16\" --extra-index-url https://download.pytorch.org/whl/cpu" + "%pip install -q \"segment_anything\" \"gradio>=4.13\" \"openvino>=2023.1.0\" \"nncf>=2.5.0\" \"torch>=2.1\" \"torchvision>=0.16\" --extra-index-url https://download.pytorch.org/whl/cpu" ] }, { diff --git a/notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb b/notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb index 9bfb741a7ac..fe39ae3dc2e 100644 --- a/notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb +++ b/notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb @@ -62,7 +62,7 @@ "%pip install -q \"ultralytics==8.0.200\" onnx --extra-index-url https://download.pytorch.org/whl/cpu\n", "%pip install -q \"openvino-dev>=2023.1.0\"\n", "%pip install -q \"nncf>=2.6.0\"\n", - "%pip install -q \"gradio<4.9\"" + "%pip install -q \"gradio>=4.13\"" ] }, { diff --git a/notebooks/272-paint-by-example/272-paint-by-example.ipynb b/notebooks/272-paint-by-example/272-paint-by-example.ipynb index 185c094bd58..35b20a0b2b6 100644 --- a/notebooks/272-paint-by-example/272-paint-by-example.ipynb +++ b/notebooks/272-paint-by-example/272-paint-by-example.ipynb @@ -64,8 +64,9 @@ } ], "source": [ - "%pip install -q \"gradio>=3.50.2\"\n", - "%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\"" + "%pip install -q \"gradio>=4.10.0\"\n", + "%pip install -q torch torchvision --extra-index-url \"https://download.pytorch.org/whl/cpu\"\n", + "%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\" ipywidgets opencv_python" ] }, { @@ -1151,37 +1152,36 @@ "example = {}\n", "ref_dir = 'data/reference'\n", "image_dir = 'data/image'\n", - "ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir)]\n", + "ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir) if file.endswith(\".jpg\")]\n", "ref_list.sort()\n", - "image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir)]\n", + "image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir) if file.endswith(\".png\")]\n", "image_list.sort()\n", "\n", "\n", "image_blocks = gr.Blocks()\n", "with image_blocks as demo:\n", " with gr.Group():\n", - " with gr.Box():\n", - " with gr.Row():\n", - " with gr.Column():\n", - " image = gr.Image(source='upload', tool='sketch', elem_id=\"image_upload\", type=\"pil\", label=\"Source Image\")\n", - " reference = gr.Image(source='upload', elem_id=\"image_upload\", type=\"pil\", label=\"Reference Image\")\n", - "\n", - " with gr.Column():\n", - " image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n", - " steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n", - "\n", - " seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n", - "\n", - " with gr.Row(elem_id=\"prompt-container\"):\n", - " btn = gr.Button(\"Paint!\")\n", - " \n", - " with gr.Row():\n", - " with gr.Column():\n", - " gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n", - " with gr.Column():\n", - " gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n", - " \n", - " btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n", + " with gr.Row():\n", + " with gr.Column():\n", + " image = gr.ImageEditor(sources=['upload'], type=\"pil\", label=\"Source Image\")\n", + " reference = gr.Image(sources=['upload'], type=\"pil\", label=\"Reference Image\")\n", + "\n", + " with gr.Column():\n", + " image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n", + " steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n", + "\n", + " seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n", + "\n", + " with gr.Row(elem_id=\"prompt-container\"):\n", + " btn = gr.Button(\"Paint!\")\n", + " \n", + " with gr.Row():\n", + " with gr.Column():\n", + " gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n", + " with gr.Column():\n", + " gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n", + " \n", + " btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n", "\n", "# Launching the Gradio app\n", "try:\n", diff --git a/notebooks/274-efficient-sam/274-efficient-sam.ipynb b/notebooks/274-efficient-sam/274-efficient-sam.ipynb index 4e34d02f230..df1cf877551 100644 --- a/notebooks/274-efficient-sam/274-efficient-sam.ipynb +++ b/notebooks/274-efficient-sam/274-efficient-sam.ipynb @@ -54,7 +54,7 @@ "outputs": [], "source": [ "%pip uninstall -y -q openvino openvino-dev openvino-nightly\n", - "%pip install -q openvino-nightly \"nncf>=2.7\" opencv-python matplotlib \"gradio<4.9\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu" + "%pip install -q openvino-nightly \"nncf>=2.7\" opencv-python matplotlib \"gradio>=4.13\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu" ] }, {