Skip to content

[ONNX] Don't download ONNX model by default #4338

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

Merged
merged 8 commits into from
Jul 28, 2023
Merged

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Jul 28, 2023

What does this PR do?

This PR makes sure that ONNX weights are only ever by default downloaded by ONNX pipelines, but not any PyTorch pipelines.

The user is also given the option to have more fine-grained control via a use_onnx download argument.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 28, 2023

The documentation is not available anymore as the PR was closed or merged.

@@ -1411,6 +1412,9 @@ def download(cls, pretrained_model_name, **kwargs) -> Union[str, os.PathLike]:
):
ignore_patterns = ["*.bin", "*.msgpack"]

if not use_onnx:
Copy link
Contributor

@echarlaix echarlaix Jul 28, 2023

Choose a reason for hiding this comment

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

Should this be set by default for all the OnnxStableDiffusionXxxPipeline ?

@patrickvonplaten patrickvonplaten changed the title Fix onnx download [ONNX] Don't download ONNX model by default Jul 28, 2023
Copy link
Contributor

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

@patrickvonplaten patrickvonplaten merged commit 306a7bd into main Jul 28, 2023
@patrickvonplaten patrickvonplaten deleted the fix_onnx_download branch July 28, 2023 13:11
sayakpaul pushed a commit that referenced this pull request Jul 28, 2023
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
@JacquiML
Copy link
Contributor

Hey @sayakpaul , in from_pretrained func, when calling cls.download, should we as use_onnx as an input parameter?
current:

 if not os.path.isdir(pretrained_model_name_or_path):
            cached_folder = cls.download(
                pretrained_model_name_or_path,
                cache_dir=cache_dir,
                resume_download=resume_download,
                force_download=force_download,
                proxies=proxies,
                local_files_only=local_files_only,
                use_auth_token=use_auth_token,
                revision=revision,
                from_flax=from_flax,
                use_safetensors=use_safetensors,
                custom_pipeline=custom_pipeline,
                custom_revision=custom_revision,
                variant=variant,
                load_connected_pipeline=load_connected_pipeline,
                **kwargs,
            )

proposed (added use_onnx=use_onnx,):

 if not os.path.isdir(pretrained_model_name_or_path):
            cached_folder = cls.download(
                pretrained_model_name_or_path,
                cache_dir=cache_dir,
                resume_download=resume_download,
                force_download=force_download,
                proxies=proxies,
                local_files_only=local_files_only,
                use_auth_token=use_auth_token,
                revision=revision,
                from_flax=from_flax,
                use_safetensors=use_safetensors,
                use_onnx=use_onnx,
                custom_pipeline=custom_pipeline,
                custom_revision=custom_revision,
                variant=variant,
                load_connected_pipeline=load_connected_pipeline,
                **kwargs,
            )

@sayakpaul
Copy link
Member

@patrickvonplaten ^.

orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
@patrickvonplaten
Copy link
Contributor Author

Hey @JacquiML,

Good point! Would you like to open a PR for this?

@JacquiML
Copy link
Contributor

JacquiML commented Aug 3, 2023

Hey @JacquiML,

Good point! Would you like to open a PR for this?

sure :)

yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* [Download] Don't download ONNX weights by default

* fix more

* finish

* finish

* finish
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.

5 participants