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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable the detailed view of the gallery #4470

Merged
merged 4 commits into from Jun 12, 2023

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Jun 9, 2023

Description

Closes: #3763

You can test by making the following change to fake_gan

  gallery = gr.Gallery(
      label="Generated images",
      show_label=False,
      elem_id="gallery",
      detailed_view=False,
)

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 馃憢 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4470-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review June 9, 2023 23:35
@freddyaboulton freddyaboulton requested review from pngwn, aliabid94, abidlabs, aliabd, dawoodkhan82 and hannahblair and removed request for pngwn June 9, 2023 23:37
Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @freddyaboulton. Tested the parameter directly and with .update() and works great!

@pngwn
Copy link
Member

pngwn commented Jun 11, 2023

Is there a better term than detailed view? Maybe full screen or zoomed or something?

@freddyaboulton
Copy link
Collaborator Author

@pngwn How about zoom_on_click?

@abidlabs
Copy link
Member

abidlabs commented Jun 12, 2023

Actually we have an existing parameter preview which sets the Gallery to be in "preview" mode by default. To be consistent, how about we call this parameter allow_preview. We should also add to the docstring of preview that it only has any effect if allow_preview is True.

Some test code confirming preview has no effect if this parameter is False:

import gradio as gr

def test(x: gr.SelectData):
    print(x.index)
    


with gr.Blocks() as demo:
    gallery = gr.Gallery(
        ["cheetah.jpg"]*4,
        preview=True,
        detailed_view=False 
    )
    gallery.select(test, None, None)
    
demo.launch()

@freddyaboulton
Copy link
Collaborator Author

Sounds good @abidlabs! In hindsight, we should have renamed preview parameter better. Will make a note of this in the 4.0 component cleanup tracking issue.

Yes, preview should have no effect if allow_preview is False

@abidlabs
Copy link
Member

Agreed about the naming 馃槄

@freddyaboulton freddyaboulton force-pushed the 3763-disable-detailed-view-gallery branch from 6df101b to 5c93129 Compare June 12, 2023 21:01
@freddyaboulton
Copy link
Collaborator Author

Thanks @abidlabs ! Renamed to allow_preview! Merging now

@freddyaboulton freddyaboulton merged commit 3383d88 into main Jun 12, 2023
12 of 16 checks passed
@freddyaboulton freddyaboulton deleted the 3763-disable-detailed-view-gallery branch June 12, 2023 21:11
@freddyaboulton freddyaboulton mentioned this pull request Jun 12, 2023
47 tasks
@pngwn
Copy link
Member

pngwn commented Jun 14, 2023

Sorry for late reply but I like the new name. preview is what I had in mind when I made the original comment but I couldn't remember the actual name!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a feature to disable the detailed view in gr.Gallery
4 participants