Skip to content

Commit

Permalink
[Gradio] Fix deprecated method calls (#1422)
Browse files Browse the repository at this point in the history
* Apply gradio deprecation errors fix

Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>

* Replace .style and gr.Box usages

Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>

* Apply review comments

Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>

* Add upper bound for torch version

Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>

---------

Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>
  • Loading branch information
itrushkin authored Nov 9, 2023
1 parent d527de0 commit a9fccc6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
14 changes: 10 additions & 4 deletions notebooks/223-text-prediction/223-text-prediction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -766,20 +766,26 @@
" return history\n",
"\n",
" with gr.Blocks() as demo:\n",
" chatbot = gr.Chatbot([], elem_id=\"chatbot\").style()\n",
" chatbot = gr.Chatbot([], elem_id=\"chatbot\")\n",
"\n",
" with gr.Row():\n",
" with gr.Column():\n",
" txt = gr.Textbox(\n",
" show_label=False,\n",
" placeholder=\"Enter text and press enter, or upload an image\",\n",
" ).style(container=False)\n",
" container=False\n",
" )\n",
"\n",
" txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(\n",
" bot, chatbot, chatbot\n",
" )\n",
"\n",
" demo.launch()\n",
" try:\n",
" demo.launch(debug=True)\n",
" except Exception:\n",
" demo.launch(debug=True, share=True)\n",
" # if you are launching remotely, specify server_name and server_port\n",
" # demo.launch(server_name='your server name', server_port='server port in int')\n",
" # Read more in the docs: https://gradio.app/docs/\n",
"else:\n",
" print(\"Selected Model is not PersonaGPT, Please select PersonaGPT in the first cell to have a conversation\")"
]
Expand Down
14 changes: 2 additions & 12 deletions notebooks/237-segment-anything/237-segment-anything.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,6 @@
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_862585/1907223323.py:46: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.\n",
" input_img = gr.Image(label=\"Input\", type=\"numpy\").style(height=480, width=480)\n",
"/tmp/ipykernel_862585/1907223323.py:47: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.\n",
" output_img = gr.Image(label=\"Selected Segment\", type=\"numpy\").style(height=480, width=480)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down Expand Up @@ -1194,8 +1184,8 @@
" \n",
"with gr.Blocks() as demo:\n",
" with gr.Row():\n",
" input_img = gr.Image(label=\"Input\", type=\"numpy\").style(height=480, width=480)\n",
" output_img = gr.Image(label=\"Selected Segment\", type=\"numpy\").style(height=480, width=480)\n",
" input_img = gr.Image(label=\"Input\", type=\"numpy\", height=480, width=480)\n",
" output_img = gr.Image(label=\"Selected Segment\", type=\"numpy\", height=480, width=480)\n",
" \n",
" def on_image_change(img):\n",
" segmenter.set_image(img)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,13 @@
"\n",
"if __name__ == \"__main__\":\n",
" try:\n",
" demo.launch(enable_queue=True, share=False, height=800)\n",
" demo.queue().launch(debug=True, height=800)\n",
" except Exception:\n",
" demo.launch(enable_queue=True, share=True, height=800)"
" demo.queue().launch(debug=True, share=True, height=800)\n",
"\n",
"# If you are launching remotely, specify server_name and server_port\n",
"# EXAMPLE: `demo.launch(server_name='your server name', server_port='server port in int')`\n",
"# To learn more please refer to the Gradio docs: https://gradio.app/docs/"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"outputs": [],
"source": [
"%pip install -q \"diffusers>=0.16.1\" \"transformers>=4.28.0\"\n",
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu torch torchaudio\n",
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"torch<2.1\" \"torchaudio<2.1\"\n",
"%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\" onnx onnxruntime \"gradio>=3.34.0\" \"openvino>=2023.1.0\""
]
},
Expand Down Expand Up @@ -631,23 +631,26 @@
" \n",
" with gr.Column():\n",
" sound_output = gr.Audio(type='filepath', label=\"spectrogram sound\")\n",
" spectrogram_output = gr.Image(label=\"spectrogram image result\")\n",
" spectrogram_output.style(height=256)\n",
" spectrogram_output = gr.Image(label=\"spectrogram image result\", height=256)\n",
" \n",
" send_btn.click(generate, inputs=[prompt_input, negative_prompt], outputs=[spectrogram_output, sound_output])\n",
" device.change(select_device, [device, prompt_input], [prompt_input])\n",
"\n",
"if __name__ == \"__main__\":\n",
" try:\n",
" demo.launch(enable_queue=True, height=800)\n",
" demo.queue().launch(debug=True, height=800)\n",
" except Exception:\n",
" demo.launch(enable_queue=True, share=True, height=800)"
" demo.queue().launch(debug=True, share=True, height=800)\n",
"\n",
"# If you are launching remotely, specify server_name and server_port\n",
"# EXAMPLE: `demo.launch(server_name='your server name', server_port='server port in int')`\n",
"# To learn more please refer to the Gradio docs: https://gradio.app/docs/"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -661,7 +664,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@
" gr.Markdown(DESCRIPTION)\n",
" with gr.Row():\n",
" with gr.Column():\n",
" with gr.Box():\n",
" with gr.Group():\n",
" image1 = gr.Image(label=\"Image 1\", type=\"pil\")\n",
" gr.Examples(\n",
" examples=[\"fastcomposer/data/newton.jpeg\"],\n",
Expand Down Expand Up @@ -1219,9 +1219,7 @@
" value=50,\n",
" )\n",
" with gr.Column():\n",
" result = gr.Gallery(label=\"Generated Images\").style(\n",
" grid=[2], height=\"auto\"\n",
" )\n",
" result = gr.Gallery(label=\"Generated Images\", columns=[2])\n",
" error_message = gr.Text(label=\"Job Status\")\n",
"\n",
" inputs = [\n",
Expand Down

0 comments on commit a9fccc6

Please sign in to comment.