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

Add a simpleimage template for custom components #7129

Merged
merged 20 commits into from Jan 27, 2024
Merged

Add a simpleimage template for custom components #7129

merged 20 commits into from Jan 27, 2024

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Jan 23, 2024

Adds a SimpleImage template as I think many users may want to template off of the Image component to get the upload/drag + preview behavior, but the regular Image component has a lot of extra functionality that is not needed (e.g. sharing to HF, support for multiple sources, various PIL-related preprocessing, the .select() event)

I built SimpleImage as a custom component myself so it works as a component, but I'm not sure if it can be used as a template or if I need to do something else besides place the files in the right place. Would appreciate any insights @freddyaboulton @pngwn

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 23, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/06c616103fcd6c36262b642b1b4940a95ffcad4b/gradio-4.16.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@06c616103fcd6c36262b642b1b4940a95ffcad4b#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 23, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
@gradio/simpleimage minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Add a simpleimage template for custom components

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

elif component.template in gradio._simple_templates.__all__: # type: ignore
module = "_simple_templates"
else:
def find_template_in_list(template, list_to_search):
Copy link
Member Author

@abidlabs abidlabs Jan 26, 2024

Choose a reason for hiding this comment

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

It was bothering me that the parameter to --template was case sensitive. This change makes it case-insensitive

@abidlabs abidlabs marked this pull request as ready for review January 26, 2024 17:06
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Nice PR @abidlabs - left some nits

gradio/_simple_templates/simpleimage.py Show resolved Hide resolved
gradio/_simple_templates/simpleimage.py Outdated Show resolved Hide resolved
gradio/_simple_templates/simpleimage.py Outdated Show resolved Hide resolved
@abidlabs
Copy link
Member Author

abidlabs commented Jan 27, 2024

Thanks @freddyaboulton and @pngwn. I've made the changes and I'll go ahead and merge this in.

I'll bother you later if it doesn't work as a template

@abidlabs abidlabs merged commit ccdaec4 into main Jan 27, 2024
11 checks passed
@abidlabs abidlabs deleted the simpleimage branch January 27, 2024 01:29
@pngwn pngwn mentioned this pull request Jan 26, 2024
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.

None yet

4 participants