Skip to content

Commit

Permalink
Fix Gradio deprecated functionality in 272-paint-by-example (#1598)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
itrushkin authored Jan 9, 2024
1 parent 9cef24a commit 76121ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion notebooks/237-segment-anything/237-segment-anything.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
]
},
{
Expand Down
52 changes: 26 additions & 26 deletions notebooks/272-paint-by-example/272-paint-by-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/274-efficient-sam/274-efficient-sam.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down

0 comments on commit 76121ac

Please sign in to comment.