Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/diffusers/modeling_flax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
from requests import HTTPError

from . import is_torch_available
from . import __version__, is_torch_available
from .modeling_flax_pytorch_utils import convert_pytorch_state_dict_to_flax
from .utils import (
CONFIG_NAME,
Expand Down Expand Up @@ -286,10 +286,13 @@ def from_pretrained(
local_files_only = kwargs.pop("local_files_only", False)
use_auth_token = kwargs.pop("use_auth_token", None)
revision = kwargs.pop("revision", None)
from_auto_class = kwargs.pop("_from_auto", False)
subfolder = kwargs.pop("subfolder", None)

user_agent = {"file_type": "model", "framework": "flax", "from_auto_class": from_auto_class}
user_agent = {
"diffusers": __version__,
"file_type": "model",
"framework": "flax",
}

# Load config if we don't provide a configuration
config_path = config if config is not None else pretrained_model_name_or_path
Expand Down
8 changes: 6 additions & 2 deletions src/diffusers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
from requests import HTTPError

from . import __version__
from .utils import CONFIG_NAME, DIFFUSERS_CACHE, HUGGINGFACE_CO_RESOLVE_ENDPOINT, WEIGHTS_NAME, logging


Expand Down Expand Up @@ -292,12 +293,15 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
local_files_only = kwargs.pop("local_files_only", False)
use_auth_token = kwargs.pop("use_auth_token", None)
revision = kwargs.pop("revision", None)
from_auto_class = kwargs.pop("_from_auto", False)
torch_dtype = kwargs.pop("torch_dtype", None)
subfolder = kwargs.pop("subfolder", None)
device_map = kwargs.pop("device_map", None)

user_agent = {"file_type": "model", "framework": "pytorch", "from_auto_class": from_auto_class}
user_agent = {
"diffusers": __version__,
"file_type": "model",
"framework": "pytorch",
}

# Load config if we don't provide a configuration
config_path = pretrained_model_name_or_path
Expand Down
7 changes: 7 additions & 0 deletions src/diffusers/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from PIL import Image
from tqdm.auto import tqdm

from . import __version__
from .configuration_utils import ConfigMixin
from .dynamic_modules_utils import get_class_from_dynamic_module
from .schedulers.scheduling_utils import SCHEDULER_CONFIG_NAME
Expand Down Expand Up @@ -373,6 +374,11 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
if custom_pipeline is not None:
allow_patterns += [CUSTOM_PIPELINE_FILE_NAME]

requested_pipeline_class = config_dict.get("_class_name", cls.__name__)
Copy link
Member Author

Choose a reason for hiding this comment

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

This should cover all cases, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that'll be a very powerful metric - nice!

user_agent = {"diffusers": __version__, "pipeline_class": requested_pipeline_class}
if custom_pipeline is not None:
user_agent["custom_pipeline"] = custom_pipeline

# download all allow_patterns
cached_folder = snapshot_download(
pretrained_model_name_or_path,
Expand All @@ -383,6 +389,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
use_auth_token=use_auth_token,
revision=revision,
allow_patterns=allow_patterns,
user_agent=user_agent,
)
else:
cached_folder = pretrained_model_name_or_path
Expand Down