MCPcopy
hub / github.com/huggingface/diffusers / _get_load_method

Function _get_load_method

src/diffusers/pipelines/pipeline_loading_utils.py:938–951  ·  view source on GitHub ↗

Return the method to load the sub model. In practice, this method will return the `"from_pretrained"` (or `load_method_name`) method of the class object except if loading from a DDUF checkpoint. In that case, transformers models and tokenizers have a specific loading method that we

(class_obj: object, load_method_name: str, is_dduf: bool)

Source from the content-addressed store, hash-verified

936
937
938def _get_load_method(class_obj: object, load_method_name: str, is_dduf: bool) -> Callable:
939 """
940 Return the method to load the sub model.
941
942 In practice, this method will return the `"from_pretrained"` (or `load_method_name`) method of the class object
943 except if loading from a DDUF checkpoint. In that case, transformers models and tokenizers have a specific loading
944 method that we need to use.
945 """
946 if is_dduf:
947 if issubclass(class_obj, PreTrainedTokenizerBase):
948 return lambda *args, **kwargs: _load_tokenizer_from_dduf(class_obj, *args, **kwargs)
949 if issubclass(class_obj, PreTrainedModel):
950 return lambda *args, **kwargs: _load_transformers_model_from_dduf(class_obj, *args, **kwargs)
951 return getattr(class_obj, load_method_name)
952
953
954def _fetch_class_library_tuple(module):

Callers 1

load_sub_modelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…