[Python] Gradio "AttributeError: 'Image' object has no attribute 'proxy_url'"

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    Since the Gradio Discord server is busy or does not allow new requests, I'm posting this here. I intend to display an image in the rows of a Gradio Dataset. The error is "AttributeError: 'Image' object has no attribute 'proxy_url'" and seems deep in the implementation of Gradio, so the AI did not help to understand the context.

    python -c "import gradio as gr; import sys; print(f'Python {sys.version.split()[0]}\\nGradio {gr.__version__}')"

    Python 3.11.11
    Gradio 5.23.3


    This is the error stack:

    File "src/test_001.py", line 18, in show_startup_quotes
    return gr.Dataset(
    ^^^^^^^^^^^
    File ".venv/lib/python3.11/site-packages/gradio/component_meta.py", line 182, in wrapper
    return fn(self, **kwargs)
    ^^^^^^^^^^^^^^^^^^
    File ".venv/lib/python3.11/site-packages/gradio/components/dataset.py", line 86, in __init__
    self.component_props = [
    ^
    File ".venv/lib/python3.11/site-packages/gradio/components/dataset.py", line 88, in <listcomp>
    component.get_config(),
    ^^^^^^^^^^^^^^^^^^^^^^
    File ".venv/lib/python3.11/site-packages/gradio/components/base.py", line 245, in get_config
    config = super().get_config()
    ^^^^^^^^^^^^^^^^^^^^
    File ".venv/lib/python3.11/site-packages/gradio/blocks.py", line 266, in get_config
    config = {**config, "proxy_url": self.proxy_url, "name": self.get_block_class()}


    Here is the code to reproduce

    import gradio as gr
    from PIL import Image

    white_image = Image.new("RGBA", (16, 16), color=(0, 0, 0, 0))
    red_image = Image.new("RGBA", (16, 16), color=(255, 0, 0, 255))

    philosophy_quotes = [
    [white_image, "I think therefore I am."],
    [white_image, "The unexamined life is not worth living."]
    ]

    startup_quotes = [
    [red_image, "Ideas are easy. Implementation is hard"],
    [red_image, "Make mistakes faster."]
    ]

    def show_startup_quotes():
    return gr.Dataset(
    samples=startup_quotes,
    components=[
    gr.Image(type="pil"),
    gr.Text()
    ])

    with gr.Blocks() as demo:
    textbox = gr.Textbox()
    image = gr.Image(visible=False,type="pil")
    dataset = gr.Dataset(components=[textbox, image], samples=philosophy_quotes)
    button = gr.Button()

    button.click(show_startup_quotes, None, dataset)

    demo.launch()


    Any hints?

    Continue reading...

Compartilhe esta Página