Skip to content

Commit 76121ac

Browse files
authored
Fix Gradio deprecated functionality in 272-paint-by-example (#1598)
* Fix gradio deprecated functionality Signed-off-by: Ilya Trushkin <[email protected]> * Resolve pip conflicts Signed-off-by: Ilya Trushkin <[email protected]> --------- Signed-off-by: Ilya Trushkin <[email protected]>
1 parent 9cef24a commit 76121ac

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

notebooks/237-segment-anything/237-segment-anything.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"metadata": {},
8080
"outputs": [],
8181
"source": [
82-
"%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"
82+
"%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"
8383
]
8484
},
8585
{

notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"%pip install -q \"ultralytics==8.0.200\" onnx --extra-index-url https://download.pytorch.org/whl/cpu\n",
6363
"%pip install -q \"openvino-dev>=2023.1.0\"\n",
6464
"%pip install -q \"nncf>=2.6.0\"\n",
65-
"%pip install -q \"gradio<4.9\""
65+
"%pip install -q \"gradio>=4.13\""
6666
]
6767
},
6868
{

notebooks/272-paint-by-example/272-paint-by-example.ipynb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@
6464
}
6565
],
6666
"source": [
67-
"%pip install -q \"gradio>=3.50.2\"\n",
68-
"%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\""
67+
"%pip install -q \"gradio>=4.10.0\"\n",
68+
"%pip install -q torch torchvision --extra-index-url \"https://download.pytorch.org/whl/cpu\"\n",
69+
"%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\" ipywidgets opencv_python"
6970
]
7071
},
7172
{
@@ -1151,37 +1152,36 @@
11511152
"example = {}\n",
11521153
"ref_dir = 'data/reference'\n",
11531154
"image_dir = 'data/image'\n",
1154-
"ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir)]\n",
1155+
"ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir) if file.endswith(\".jpg\")]\n",
11551156
"ref_list.sort()\n",
1156-
"image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir)]\n",
1157+
"image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir) if file.endswith(\".png\")]\n",
11571158
"image_list.sort()\n",
11581159
"\n",
11591160
"\n",
11601161
"image_blocks = gr.Blocks()\n",
11611162
"with image_blocks as demo:\n",
11621163
" with gr.Group():\n",
1163-
" with gr.Box():\n",
1164-
" with gr.Row():\n",
1165-
" with gr.Column():\n",
1166-
" image = gr.Image(source='upload', tool='sketch', elem_id=\"image_upload\", type=\"pil\", label=\"Source Image\")\n",
1167-
" reference = gr.Image(source='upload', elem_id=\"image_upload\", type=\"pil\", label=\"Reference Image\")\n",
1168-
"\n",
1169-
" with gr.Column():\n",
1170-
" image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n",
1171-
" steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n",
1172-
"\n",
1173-
" seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n",
1174-
"\n",
1175-
" with gr.Row(elem_id=\"prompt-container\"):\n",
1176-
" btn = gr.Button(\"Paint!\")\n",
1177-
" \n",
1178-
" with gr.Row():\n",
1179-
" with gr.Column():\n",
1180-
" gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n",
1181-
" with gr.Column():\n",
1182-
" gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n",
1183-
" \n",
1184-
" btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n",
1164+
" with gr.Row():\n",
1165+
" with gr.Column():\n",
1166+
" image = gr.ImageEditor(sources=['upload'], type=\"pil\", label=\"Source Image\")\n",
1167+
" reference = gr.Image(sources=['upload'], type=\"pil\", label=\"Reference Image\")\n",
1168+
"\n",
1169+
" with gr.Column():\n",
1170+
" image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n",
1171+
" steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n",
1172+
"\n",
1173+
" seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n",
1174+
"\n",
1175+
" with gr.Row(elem_id=\"prompt-container\"):\n",
1176+
" btn = gr.Button(\"Paint!\")\n",
1177+
" \n",
1178+
" with gr.Row():\n",
1179+
" with gr.Column():\n",
1180+
" gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n",
1181+
" with gr.Column():\n",
1182+
" gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n",
1183+
" \n",
1184+
" btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n",
11851185
"\n",
11861186
"# Launching the Gradio app\n",
11871187
"try:\n",

notebooks/274-efficient-sam/274-efficient-sam.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"outputs": [],
5555
"source": [
5656
"%pip uninstall -y -q openvino openvino-dev openvino-nightly\n",
57-
"%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"
57+
"%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"
5858
]
5959
},
6060
{

0 commit comments

Comments
 (0)