@@ -360,7 +360,7 @@ def init_pipeline(
360360 collection : Optional [str ] = None ,
361361 ) -> "ModularPipeline" :
362362 """
363- create a ModularPipeline, optionally accept modular_repo to load from hub.
363+ create a ModularPipeline, optionally accept pretrained_model_name_or_path to load from hub.
364364 """
365365 pipeline_class_name = MODULAR_PIPELINE_MAPPING .get (self .model_name , ModularPipeline .__name__ )
366366 diffusers_module = importlib .import_module ("diffusers" )
@@ -1645,8 +1645,8 @@ def from_pretrained(
16451645 pretrained_model_name_or_path (`str` or `os.PathLike`, optional):
16461646 Path to a pretrained pipeline configuration. It will first try to load config from
16471647 `modular_model_index.json`, then fallback to `model_index.json` for compatibility with standard
1648- non-modular repositories. If the repo does not contain any pipeline config, it will be set to None
1649- during initialization.
1648+ non-modular repositories. If the pretrained_model_name_or_path does not contain any pipeline config, it
1649+ will be set to None during initialization.
16501650 trust_remote_code (`bool`, optional):
16511651 Whether to trust remote code when loading the pipeline, need to be set to True if you want to create
16521652 pipeline blocks based on the custom code in `pretrained_model_name_or_path`
@@ -1807,7 +1807,7 @@ def register_components(self, **kwargs):
18071807 library , class_name = None , None
18081808
18091809 # extract the loading spec from the updated component spec that'll be used as part of modular_model_index.json config
1810- # e.g. {"repo ": "stabilityai/stable-diffusion-2-1",
1810+ # e.g. {"pretrained_model_name_or_path ": "stabilityai/stable-diffusion-2-1",
18111811 # "type_hint": ("diffusers", "UNet2DConditionModel"),
18121812 # "subfolder": "unet",
18131813 # "variant": None,
@@ -2111,8 +2111,10 @@ def load_components(self, names: Optional[Union[List[str], str]] = None, **kwarg
21112111 **kwargs: additional kwargs to be passed to `from_pretrained()`.Can be:
21122112 - a single value to be applied to all components to be loaded, e.g. torch_dtype=torch.bfloat16
21132113 - a dict, e.g. torch_dtype={"unet": torch.bfloat16, "default": torch.float32}
2114- - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g. `repo`,
2115- `variant`, `revision`, etc.
2114+ - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g.
2115+ `pretrained_model_name_or_path`, `variant`, `revision`, etc.
2116+ - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g.
2117+ `pretrained_model_name_or_path`, `variant`, `revision`, etc.
21162118 """
21172119
21182120 if names is None :
@@ -2378,10 +2380,10 @@ def _component_spec_to_dict(component_spec: ComponentSpec) -> Any:
23782380 - "type_hint": Tuple[str, str]
23792381 Library name and class name of the component. (e.g. ("diffusers", "UNet2DConditionModel"))
23802382 - All loading fields defined by `component_spec.loading_fields()`, typically:
2381- - "repo ": Optional[str]
2382- The model repository (e.g., "stabilityai/stable-diffusion-xl").
2383+ - "pretrained_model_name_or_path ": Optional[str]
2384+ The model pretrained_model_name_or_pathsitory (e.g., "stabilityai/stable-diffusion-xl").
23832385 - "subfolder": Optional[str]
2384- A subfolder within the repo where this component lives.
2386+ A subfolder within the pretrained_model_name_or_path where this component lives.
23852387 - "variant": Optional[str]
23862388 An optional variant identifier for the model.
23872389 - "revision": Optional[str]
@@ -2398,11 +2400,13 @@ def _component_spec_to_dict(component_spec: ComponentSpec) -> Any:
23982400 Example:
23992401 >>> from diffusers.pipelines.modular_pipeline_utils import ComponentSpec >>> from diffusers import
24002402 UNet2DConditionModel >>> spec = ComponentSpec(
2401- ... name="unet", ... type_hint=UNet2DConditionModel, ... config=None, ... repo="path/to/repo", ...
2402- subfolder="subfolder ", ... variant=None, ... revision=None , ...
2403- default_creation_method="from_pretrained",
2403+ ... name="unet", ... type_hint=UNet2DConditionModel, ... config=None, ...
2404+ pretrained_model_name_or_path="path/to/pretrained_model_name_or_path ", ... subfolder="subfolder" , ...
2405+ variant=None, ... revision=None, ... default_creation_method="from_pretrained",
24042406 ... ) >>> ModularPipeline._component_spec_to_dict(spec) {
2405- "type_hint": ("diffusers", "UNet2DConditionModel"), "repo": "path/to/repo", "subfolder": "subfolder",
2407+ "type_hint": ("diffusers", "UNet2DConditionModel"), "pretrained_model_name_or_path": "path/to/repo",
2408+ "subfolder": "subfolder", "variant": None, "revision": None, "type_hint": ("diffusers",
2409+ "UNet2DConditionModel"), "pretrained_model_name_or_path": "path/to/repo", "subfolder": "subfolder",
24062410 "variant": None, "revision": None,
24072411 }
24082412 """
@@ -2432,10 +2436,10 @@ def _dict_to_component_spec(
24322436 - "type_hint": Tuple[str, str]
24332437 Library name and class name of the component. (e.g. ("diffusers", "UNet2DConditionModel"))
24342438 - All loading fields defined by `component_spec.loading_fields()`, typically:
2435- - "repo ": Optional[str]
2439+ - "pretrained_model_name_or_path ": Optional[str]
24362440 The model repository (e.g., "stabilityai/stable-diffusion-xl").
24372441 - "subfolder": Optional[str]
2438- A subfolder within the repo where this component lives.
2442+ A subfolder within the pretrained_model_name_or_path where this component lives.
24392443 - "variant": Optional[str]
24402444 An optional variant identifier for the model.
24412445 - "revision": Optional[str]
@@ -2452,11 +2456,20 @@ def _dict_to_component_spec(
24522456 ComponentSpec: A reconstructed ComponentSpec object.
24532457
24542458 Example:
2455- >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ... "repo":
2456- "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant": None, ... "revision": None, ...
2457- } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict) ComponentSpec(
2458- name="unet", type_hint=UNet2DConditionModel, config=None, repo="stabilityai/stable-diffusion-xl",
2459- subfolder="unet", variant=None, revision=None, default_creation_method="from_pretrained"
2459+ >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ...
2460+ "pretrained_model_name_or_path": "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant":
2461+ None, ... "revision": None, ... } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict)
2462+ ComponentSpec(
2463+ name="unet", type_hint=UNet2DConditionModel, config=None,
2464+ pretrained_model_name_or_path="stabilityai/stable-diffusion-xl", subfolder="unet", variant=None,
2465+ revision=None, default_creation_method="from_pretrained"
2466+ >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ...
2467+ "pretrained_model_name_or_path": "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant":
2468+ None, ... "revision": None, ... } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict)
2469+ ComponentSpec(
2470+ name="unet", type_hint=UNet2DConditionModel, config=None,
2471+ pretrained_model_name_or_path="stabilityai/stable-diffusion-xl", subfolder="unet", variant=None,
2472+ revision=None, default_creation_method="from_pretrained"
24602473 )
24612474 """
24622475 # make a shallow copy so we can pop() safely
0 commit comments