-
Notifications
You must be signed in to change notification settings - Fork 6.5k
[trust remote code] Additional features #5491
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sayakpaul
commented
Oct 25, 2023
Comment on lines
+173
to
+186
| # Additionally, save the implementation file too. It can happen for a pipeline, for a model, and | ||
| # for a scheduler. | ||
| if self.__class__.__name__ not in _all_available_pipeline_component_modules: | ||
| module_to_save = self.__class__.__module__ | ||
| absolute_module_path = sys.modules[module_to_save].__file__ | ||
| try: | ||
| with open(absolute_module_path, "r") as original_file: | ||
| content = original_file.read() | ||
| path_to_write = os.path.join(save_directory, f"{module_to_save}.py") | ||
| with open(path_to_write, "w") as new_file: | ||
| new_file.write(content) | ||
| logger.info(f"{module_to_save}.py saved in {save_directory}") | ||
| except Exception as e: | ||
| logger.error(e) |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also parameterize this based on a function argument if that's preferred.
Member
Author
|
Closing in favor of #5556. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From the model card of https://huggingface.co/hf-internal-testing/tiny-sdxl-custom-all, if we run
it will lead to:
To reproduce, you must clear the cache associated with
hf-internal-testing/tiny-sdxl-custom-all.This PR fixes that.
Additionally, this PR adds the functionality to serialize the module files with the pipeline making it easy for users to share a self-contained pipeline repository on the Hub that can be readily loaded with
trust_remote_code=Truewithout having to go through the steps outlined here: #5472 (comment). Here's a gist to test it all out: https://gist.github.com/sayakpaul/685d263df0bd845cbe8997ebd468a5c5.More comments inline.