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

Format image provider #66

Merged
merged 15 commits into from
May 1, 2023
Merged

Conversation

JasonWeill
Copy link
Collaborator

@JasonWeill JasonWeill commented Apr 14, 2023

Fixes #44.

Adds modified huggingface_hub provider that calls HuggingFace models and returns an image as Base64-encoded bytes. Adds an image format type that decodes encoded images.

image

@JasonWeill JasonWeill added enhancement New feature or request @jupyter-ai/magics labels Apr 14, 2023
@JasonWeill JasonWeill force-pushed the format-image-provider branch 3 times, most recently from 70b1ce0 to 0987956 Compare April 17, 2023 18:12
Copy link
Collaborator

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

This looks great! You moved very fast on this, my apologies for not getting the opportunity to review this sooner.

Rather than having HF txt2img models live underneath a separate provider, can you try instead defining the implementation inside of our HfImageProvider class (with provider ID huggingface_hub)? You will want to override the following methods:

  • validate_environment()
    • Allow ("text2text-generation", "text-generation", "text-to-image")
  • _call()
    • Allow the tasks listed above
    • Handle output for both txt2txt and txt2img models

You should also be able to leverage super().<method-name>(...) instead of copying the implementation from LangChain. This would be much more robust as it would be more compatible with later releases of LangChain (that may change the implementation).

@JasonWeill
Copy link
Collaborator Author

@dlqqq The HfImageProvider class is introduced in this PR. I can modify the HfHubProvider class as you describe.

dlqqq
dlqqq previously requested changes Apr 25, 2023
packages/jupyter-ai-magics/jupyter_ai_magics/providers.py Outdated Show resolved Hide resolved
packages/jupyter-ai-magics/pyproject.toml Outdated Show resolved Hide resolved
@JasonWeill JasonWeill marked this pull request as ready for review April 27, 2023 16:46
@JasonWeill JasonWeill changed the title WIP: Format image provider Format image provider Apr 27, 2023
@JasonWeill JasonWeill dismissed dlqqq’s stale review April 28, 2023 00:35

Made changes @dlqqq requested

packages/jupyter-ai-magics/pyproject.toml Outdated Show resolved Hide resolved
docs/source/users/index.md Outdated Show resolved Hide resolved
@JasonWeill JasonWeill requested a review from dlqqq April 28, 2023 22:38
Copy link
Collaborator

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

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

Awesome work! 👍

@JasonWeill JasonWeill merged commit cea46d4 into jupyterlab:main May 1, 2023
2 checks passed
dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Adds image format

* WIP: New provider for huggingface_image

* Adds image provider to __init__

* Improve magics.

* Change raw to text.
* Add provider/model metadata to output.

* Fixing metadata handling.

* Updates user docs

* WIP: Prints debug output on initial load

* Removes debug info from load

* Removes separate provider for images

* Outputs image in Base64 format

* Removes HF image provider, updates docs

* Removes limitation of only supporting JPEG format

* Promotes VALID_TASKS out of class

* Updates error handling, image generation example notebook

* Updates dependencies per @dlqqq

---------

Co-authored-by: Brian E. Granger <brgrange@amazon.com>
Co-authored-by: Brian E. Granger <ellisonbg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request @jupyter-ai/magics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stable diffusion support with --format image
3 participants