@@ -361,7 +361,7 @@ def init_pipeline(
361361 collection : Optional [str ] = None ,
362362 ) -> "ModularPipeline" :
363363 """
364- create a ModularPipeline, optionally accept modular_repo to load from hub.
364+ create a ModularPipeline, optionally accept pretrained_model_name_or_path to load from hub.
365365 """
366366 pipeline_class_name = MODULAR_PIPELINE_MAPPING .get (self .model_name , ModularPipeline .__name__ )
367367 diffusers_module = importlib .import_module ("diffusers" )
@@ -1646,8 +1646,8 @@ def from_pretrained(
16461646 pretrained_model_name_or_path (`str` or `os.PathLike`, optional):
16471647 Path to a pretrained pipeline configuration. It will first try to load config from
16481648 `modular_model_index.json`, then fallback to `model_index.json` for compatibility with standard
1649- non-modular repositories. If the repo does not contain any pipeline config, it will be set to None
1650- during initialization.
1649+ non-modular repositories. If the pretrained_model_name_or_path does not contain any pipeline config, it
1650+ will be set to None during initialization.
16511651 trust_remote_code (`bool`, optional):
16521652 Whether to trust remote code when loading the pipeline, need to be set to True if you want to create
16531653 pipeline blocks based on the custom code in `pretrained_model_name_or_path`
@@ -1808,7 +1808,7 @@ def register_components(self, **kwargs):
18081808 library , class_name = None , None
18091809
18101810 # extract the loading spec from the updated component spec that'll be used as part of modular_model_index.json config
1811- # e.g. {"repo ": "stabilityai/stable-diffusion-2-1",
1811+ # e.g. {"pretrained_model_name_or_path ": "stabilityai/stable-diffusion-2-1",
18121812 # "type_hint": ("diffusers", "UNet2DConditionModel"),
18131813 # "subfolder": "unet",
18141814 # "variant": None,
@@ -2112,8 +2112,10 @@ def load_components(self, names: Optional[Union[List[str], str]] = None, **kwarg
21122112 **kwargs: additional kwargs to be passed to `from_pretrained()`.Can be:
21132113 - a single value to be applied to all components to be loaded, e.g. torch_dtype=torch.bfloat16
21142114 - a dict, e.g. torch_dtype={"unet": torch.bfloat16, "default": torch.float32}
2115- - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g. `repo`,
2116- `variant`, `revision`, etc.
2115+ - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g.
2116+ `pretrained_model_name_or_path`, `variant`, `revision`, etc.
2117+ - if potentially override ComponentSpec if passed a different loading field in kwargs, e.g.
2118+ `pretrained_model_name_or_path`, `variant`, `revision`, etc.
21172119 """
21182120
21192121 if names is None :
@@ -2379,10 +2381,10 @@ def _component_spec_to_dict(component_spec: ComponentSpec) -> Any:
23792381 - "type_hint": Tuple[str, str]
23802382 Library name and class name of the component. (e.g. ("diffusers", "UNet2DConditionModel"))
23812383 - All loading fields defined by `component_spec.loading_fields()`, typically:
2382- - "repo ": Optional[str]
2383- The model repository (e.g., "stabilityai/stable-diffusion-xl").
2384+ - "pretrained_model_name_or_path ": Optional[str]
2385+ The model pretrained_model_name_or_pathsitory (e.g., "stabilityai/stable-diffusion-xl").
23842386 - "subfolder": Optional[str]
2385- A subfolder within the repo where this component lives.
2387+ A subfolder within the pretrained_model_name_or_path where this component lives.
23862388 - "variant": Optional[str]
23872389 An optional variant identifier for the model.
23882390 - "revision": Optional[str]
@@ -2399,11 +2401,13 @@ def _component_spec_to_dict(component_spec: ComponentSpec) -> Any:
23992401 Example:
24002402 >>> from diffusers.pipelines.modular_pipeline_utils import ComponentSpec >>> from diffusers import
24012403 UNet2DConditionModel >>> spec = ComponentSpec(
2402- ... name="unet", ... type_hint=UNet2DConditionModel, ... config=None, ... repo="path/to/repo", ...
2403- subfolder="subfolder ", ... variant=None, ... revision=None , ...
2404- default_creation_method="from_pretrained",
2404+ ... name="unet", ... type_hint=UNet2DConditionModel, ... config=None, ...
2405+ pretrained_model_name_or_path="path/to/pretrained_model_name_or_path ", ... subfolder="subfolder" , ...
2406+ variant=None, ... revision=None, ... default_creation_method="from_pretrained",
24052407 ... ) >>> ModularPipeline._component_spec_to_dict(spec) {
2406- "type_hint": ("diffusers", "UNet2DConditionModel"), "repo": "path/to/repo", "subfolder": "subfolder",
2408+ "type_hint": ("diffusers", "UNet2DConditionModel"), "pretrained_model_name_or_path": "path/to/repo",
2409+ "subfolder": "subfolder", "variant": None, "revision": None, "type_hint": ("diffusers",
2410+ "UNet2DConditionModel"), "pretrained_model_name_or_path": "path/to/repo", "subfolder": "subfolder",
24072411 "variant": None, "revision": None,
24082412 }
24092413 """
@@ -2433,10 +2437,10 @@ def _dict_to_component_spec(
24332437 - "type_hint": Tuple[str, str]
24342438 Library name and class name of the component. (e.g. ("diffusers", "UNet2DConditionModel"))
24352439 - All loading fields defined by `component_spec.loading_fields()`, typically:
2436- - "repo ": Optional[str]
2440+ - "pretrained_model_name_or_path ": Optional[str]
24372441 The model repository (e.g., "stabilityai/stable-diffusion-xl").
24382442 - "subfolder": Optional[str]
2439- A subfolder within the repo where this component lives.
2443+ A subfolder within the pretrained_model_name_or_path where this component lives.
24402444 - "variant": Optional[str]
24412445 An optional variant identifier for the model.
24422446 - "revision": Optional[str]
@@ -2453,11 +2457,20 @@ def _dict_to_component_spec(
24532457 ComponentSpec: A reconstructed ComponentSpec object.
24542458
24552459 Example:
2456- >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ... "repo":
2457- "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant": None, ... "revision": None, ...
2458- } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict) ComponentSpec(
2459- name="unet", type_hint=UNet2DConditionModel, config=None, repo="stabilityai/stable-diffusion-xl",
2460- subfolder="unet", variant=None, revision=None, default_creation_method="from_pretrained"
2460+ >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ...
2461+ "pretrained_model_name_or_path": "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant":
2462+ None, ... "revision": None, ... } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict)
2463+ ComponentSpec(
2464+ name="unet", type_hint=UNet2DConditionModel, config=None,
2465+ pretrained_model_name_or_path="stabilityai/stable-diffusion-xl", subfolder="unet", variant=None,
2466+ revision=None, default_creation_method="from_pretrained"
2467+ >>> spec_dict = { ... "type_hint": ("diffusers", "UNet2DConditionModel"), ...
2468+ "pretrained_model_name_or_path": "stabilityai/stable-diffusion-xl", ... "subfolder": "unet", ... "variant":
2469+ None, ... "revision": None, ... } >>> ModularPipeline._dict_to_component_spec("unet", spec_dict)
2470+ ComponentSpec(
2471+ name="unet", type_hint=UNet2DConditionModel, config=None,
2472+ pretrained_model_name_or_path="stabilityai/stable-diffusion-xl", subfolder="unet", variant=None,
2473+ revision=None, default_creation_method="from_pretrained"
24612474 )
24622475 """
24632476 # make a shallow copy so we can pop() safely
0 commit comments