We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey Gradio Team,
I just wanted to let you know that the latest gradio version does not seem to be working properly with Matplotlib plots/figures.
Previous gradio versions (i.e 5.5) seem to work fine.
import gradio as gr with gr.Blocks() as demo: test_plot = gr.Plot() test_btn = gr.Button("Test", variant="primary") test_btn .click(test_fn, inputs=[], outputs=[test,plot]) demo.launch()
I use the following code to create Matplotlib plot:
def test_fn() fig, ax = plt.subplots() plt.close(fig) return fig
==================================================================
I managed to make it work like so:
I used gr.Image instead of gr.Plot
and for matplotlib part:
def test_fn(): fig, ax = plt.subplots() import io from PIL import Image out_fig = io.BytesIO() fig.savefig(out_fig, format='png') out_fig.seek(0) img = Image.open(out_fig) return img
So there is some kinda issue between latest gradio and matplotlib when it comes to gr.Plot.
Please fix it. I would really appreciate it.
Thank you.
Sinceerly,
Alex
No response
====================================================================== Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/queueing.py", line 624, in process_events response = await route_utils.call_process_api( File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/route_utils.py", line 323, in call_process_api output = await app.get_blocks().process_api( File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/blocks.py", line 2025, in process_api data = await self.postprocess_data(block_fn, result["prediction"], state) File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1831, in postprocess_data prediction_value = block.postprocess(prediction_value) File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/components/plot.py", line 138, in postprocess out_y = processing_utils.encode_plot_to_base64(value, self.format) File "/home/ubuntu/.local/lib/python3.10/site-packages/gradio/processing_utils.py", line 158, in encode_plot_to_base64 plt.savefig(output_bytes, format=fmt) File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 3019, in savefig self.canvas.print_figure(fname, **kwargs) File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 2259, in print_figure canvas = self._get_output_canvas(backend, format) File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 2188, in _get_output_canvas raise ValueError( ValueError: Format 'webp' is not supported (supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff)
Matplotlib version: 3.5.1 ======================================================== Gradio Environment Information: ------------------------------ Operating System: Linux gradio version: 5.6.0 gradio_client version: 1.4.3 ------------------------------------------------ gradio dependencies in your environment: aiofiles: 23.2.1 anyio: 4.6.2.post1 audioop-lts is not installed. fastapi: 0.115.5 ffmpy: 0.4.0 gradio-client==1.4.3 is not installed. httpx: 0.27.2 huggingface-hub: 0.26.2 jinja2: 3.0.3 markupsafe: 2.0.1 numpy: 1.21.5 orjson: 3.10.11 packaging: 21.3 pandas: 1.3.5 pillow: 9.0.1 pydantic: 2.10.1 pydub: 0.25.1 python-multipart==0.0.12 is not installed. pyyaml: 5.4.1 ruff: 0.8.0 safehttpx: 0.1.1 semantic-version: 2.10.0 starlette: 0.41.3 tomlkit==0.12.0 is not installed. typer: 0.13.1 typing-extensions: 4.12.2 urllib3: 1.26.5 uvicorn: 0.32.1 authlib; extra == 'oauth' is not installed. itsdangerous; extra == 'oauth' is not installed. gradio_client dependencies in your environment: fsspec: 2024.3.1 httpx: 0.27.2 huggingface-hub: 0.26.2 packaging: 21.3 typing-extensions: 4.12.2 websockets: 12.0
I can work around it
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Hey Gradio Team,
I just wanted to let you know that the latest gradio version does not seem to be working properly with Matplotlib plots/figures.
Previous gradio versions (i.e 5.5) seem to work fine.
Have you searched existing issues? 🔎
Reproduction
I use the following code to create Matplotlib plot:
==================================================================
I managed to make it work like so:
I used gr.Image instead of gr.Plot
and for matplotlib part:
So there is some kinda issue between latest gradio and matplotlib when it comes to gr.Plot.
Please fix it. I would really appreciate it.
Thank you.
Sinceerly,
Alex
Screenshot
No response
Logs
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: