Skip to content
New issue

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

allow_preview=False not working as expected in custom Gallery class #9910

Open
1 task done
zhristophe opened this issue Nov 6, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working pending clarification

Comments

@zhristophe
Copy link

Describe the bug

I'm using a custom Gallery class that inherits from gr.Gallery in my Gradio application. I've set the allow_preview parameter to False when creating the Gallery instance, but the preview functionality is still being triggered when I click on the images.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

  1. Create a Gradio application with the following code:
if __name__ == "__main__":  
    class Gallery(gr.Gallery):  
        def __init__(self, **kwargs):  
            super().__init__(**kwargs)  

    with gr.Blocks() as demo:  
        gallery = Gallery(allow_preview=False)  
        imgs = gr.State()  
        print(gallery.allow_preview) 

        demo.load(lambda: ["hello.png"], None, gallery)
   
    demo.launch()
  1. Run it, and observe that the print(gallery.allow_preview) statement outputs False, indicating that the allow_preview parameter is being set correctly.
  2. Click on one of the images in the gallery.
  3. Observe that the image is still being previewed, despite the allow_preview=False setting.

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.5.0
gradio_client version: 1.4.2

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.6.2.post1
audioop-lts is not installed.
fastapi: 0.115.4
ffmpy: 0.4.0
gradio-client==1.4.2 is not installed.
httpx: 0.27.2
huggingface-hub: 0.26.2
jinja2: 3.1.4
markupsafe: 2.1.5
numpy: 2.1.3
orjson: 3.10.11
packaging: 24.1
pandas: 2.2.3
pillow: 10.4.0
pydantic: 2.9.2
pydub: 0.25.1
python-multipart==0.0.12 is not installed.
pyyaml: 6.0.2
ruff: 0.7.2
safehttpx: 0.1.1
semantic-version: 2.10.0
starlette: 0.41.2
tomlkit==0.12.0 is not installed.
typer: 0.12.5
typing-extensions: 4.12.2
urllib3: 2.2.3
uvicorn: 0.32.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.10.0
httpx: 0.27.2
huggingface-hub: 0.26.2
packaging: 24.1
typing-extensions: 4.12.2
websockets: 12.0

Severity

I can work around it

@zhristophe zhristophe added the bug Something isn't working label Nov 6, 2024
@abidlabs
Copy link
Member

Hi @zhristophe can you explain why are you creating a custom subclass? We don't really support that usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending clarification
Projects
None yet
Development

No branches or pull requests

2 participants