mirror of
https://github.com/huggingface/diffusers.git
synced 2025-12-07 21:14:44 +08:00
Compare commits
2 Commits
sf-modular
...
modular-10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
317e83646d | ||
|
|
47baa47bfd |
@@ -217,6 +217,11 @@ MELLON_OUTPUT_PARAMS = {
|
||||
"display": "output",
|
||||
"type": "controlnet",
|
||||
},
|
||||
"doc": {
|
||||
"label": "Doc",
|
||||
"display": "output",
|
||||
"type": "string",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -697,67 +702,3 @@ class MellonNodeConfig(PushToHubMixin):
|
||||
blocks_names=blocks_names,
|
||||
node_type=node_type,
|
||||
)
|
||||
|
||||
|
||||
# Minimal modular registry for Mellon node configs
|
||||
class ModularMellonNodeRegistry:
|
||||
"""Registry mapping (pipeline class, blocks_name) -> list of MellonNodeConfig."""
|
||||
|
||||
def __init__(self):
|
||||
self._registry = {}
|
||||
self._initialized = False
|
||||
|
||||
def register(self, pipeline_cls: type, node_params: Dict[str, MellonNodeConfig]):
|
||||
if not self._initialized:
|
||||
_initialize_registry(self)
|
||||
self._registry[pipeline_cls] = node_params
|
||||
|
||||
def get(self, pipeline_cls: type) -> MellonNodeConfig:
|
||||
if not self._initialized:
|
||||
_initialize_registry(self)
|
||||
return self._registry.get(pipeline_cls, None)
|
||||
|
||||
def get_all(self) -> Dict[type, Dict[str, MellonNodeConfig]]:
|
||||
if not self._initialized:
|
||||
_initialize_registry(self)
|
||||
return self._registry
|
||||
|
||||
|
||||
def _register_preset_node_types(
|
||||
pipeline_cls, params_map: Dict[str, Dict[str, Any]], registry: ModularMellonNodeRegistry
|
||||
):
|
||||
"""Register all node-type presets for a given pipeline class from a params map."""
|
||||
node_configs = {}
|
||||
for node_type, spec in params_map.items():
|
||||
node_config = MellonNodeConfig(
|
||||
inputs=spec.get("inputs", []),
|
||||
model_inputs=spec.get("model_inputs", []),
|
||||
outputs=spec.get("outputs", []),
|
||||
blocks_names=spec.get("block_names", []),
|
||||
node_type=node_type,
|
||||
)
|
||||
node_configs[node_type] = node_config
|
||||
registry.register(pipeline_cls, node_configs)
|
||||
|
||||
|
||||
def _initialize_registry(registry: ModularMellonNodeRegistry):
|
||||
"""Initialize the registry and register all available pipeline configs."""
|
||||
print("Initializing registry")
|
||||
|
||||
registry._initialized = True
|
||||
|
||||
try:
|
||||
from .qwenimage.modular_pipeline import QwenImageModularPipeline
|
||||
from .qwenimage.node_utils import QwenImage_NODE_TYPES_PARAMS_MAP
|
||||
|
||||
_register_preset_node_types(QwenImageModularPipeline, QwenImage_NODE_TYPES_PARAMS_MAP, registry)
|
||||
except Exception:
|
||||
raise Exception("Failed to register QwenImageModularPipeline")
|
||||
|
||||
try:
|
||||
from .stable_diffusion_xl.modular_pipeline import StableDiffusionXLModularPipeline
|
||||
from .stable_diffusion_xl.node_utils import SDXL_NODE_TYPES_PARAMS_MAP
|
||||
|
||||
_register_preset_node_types(StableDiffusionXLModularPipeline, SDXL_NODE_TYPES_PARAMS_MAP, registry)
|
||||
except Exception:
|
||||
raise Exception("Failed to register StableDiffusionXLModularPipeline")
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
# Copyright 2025 Qwen-Image Team and The HuggingFace Team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
# mellon nodes
|
||||
QwenImage_NODE_TYPES_PARAMS_MAP = {
|
||||
"controlnet": {
|
||||
"inputs": [
|
||||
"control_image",
|
||||
"controlnet_conditioning_scale",
|
||||
"control_guidance_start",
|
||||
"control_guidance_end",
|
||||
"height",
|
||||
"width",
|
||||
],
|
||||
"model_inputs": [
|
||||
"controlnet",
|
||||
"vae",
|
||||
],
|
||||
"outputs": [
|
||||
"controlnet_out",
|
||||
],
|
||||
"block_names": ["controlnet_vae_encoder"],
|
||||
},
|
||||
"denoise": {
|
||||
"inputs": [
|
||||
"embeddings",
|
||||
"width",
|
||||
"height",
|
||||
"seed",
|
||||
"num_inference_steps",
|
||||
"guidance_scale",
|
||||
"image_latents",
|
||||
"strength",
|
||||
"controlnet",
|
||||
],
|
||||
"model_inputs": [
|
||||
"unet",
|
||||
"guider",
|
||||
"scheduler",
|
||||
],
|
||||
"outputs": [
|
||||
"latents",
|
||||
"latents_preview",
|
||||
],
|
||||
"block_names": ["denoise"],
|
||||
},
|
||||
"vae_encoder": {
|
||||
"inputs": [
|
||||
"image",
|
||||
"width",
|
||||
"height",
|
||||
],
|
||||
"model_inputs": [
|
||||
"vae",
|
||||
],
|
||||
"outputs": [
|
||||
"image_latents",
|
||||
],
|
||||
},
|
||||
"text_encoder": {
|
||||
"inputs": [
|
||||
"prompt",
|
||||
"negative_prompt",
|
||||
],
|
||||
"model_inputs": [
|
||||
"text_encoders",
|
||||
],
|
||||
"outputs": [
|
||||
"embeddings",
|
||||
],
|
||||
},
|
||||
"decoder": {
|
||||
"inputs": [
|
||||
"latents",
|
||||
],
|
||||
"model_inputs": [
|
||||
"vae",
|
||||
],
|
||||
"outputs": [
|
||||
"images",
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
# Copyright 2025 The HuggingFace Team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
SDXL_NODE_TYPES_PARAMS_MAP = {
|
||||
"controlnet": {
|
||||
"inputs": [
|
||||
"control_image",
|
||||
"controlnet_conditioning_scale",
|
||||
"control_guidance_start",
|
||||
"control_guidance_end",
|
||||
"height",
|
||||
"width",
|
||||
],
|
||||
"model_inputs": [
|
||||
"controlnet",
|
||||
],
|
||||
"outputs": [
|
||||
"controlnet_out",
|
||||
],
|
||||
"block_names": [None],
|
||||
},
|
||||
"denoise": {
|
||||
"inputs": [
|
||||
"embeddings",
|
||||
"width",
|
||||
"height",
|
||||
"seed",
|
||||
"num_inference_steps",
|
||||
"guidance_scale",
|
||||
"image_latents",
|
||||
"strength",
|
||||
# custom adapters coming in as inputs
|
||||
"controlnet",
|
||||
# ip_adapter is optional and custom; include if available
|
||||
"ip_adapter",
|
||||
],
|
||||
"model_inputs": [
|
||||
"unet",
|
||||
"guider",
|
||||
"scheduler",
|
||||
],
|
||||
"outputs": [
|
||||
"latents",
|
||||
"latents_preview",
|
||||
],
|
||||
"block_names": ["denoise"],
|
||||
},
|
||||
"vae_encoder": {
|
||||
"inputs": [
|
||||
"image",
|
||||
"width",
|
||||
"height",
|
||||
],
|
||||
"model_inputs": [
|
||||
"vae",
|
||||
],
|
||||
"outputs": [
|
||||
"image_latents",
|
||||
],
|
||||
"block_names": ["vae_encoder"],
|
||||
},
|
||||
"text_encoder": {
|
||||
"inputs": [
|
||||
"prompt",
|
||||
"negative_prompt",
|
||||
],
|
||||
"model_inputs": [
|
||||
"text_encoders",
|
||||
],
|
||||
"outputs": [
|
||||
"embeddings",
|
||||
],
|
||||
"block_names": ["text_encoder"],
|
||||
},
|
||||
"decoder": {
|
||||
"inputs": [
|
||||
"latents",
|
||||
],
|
||||
"model_inputs": [
|
||||
"vae",
|
||||
],
|
||||
"outputs": [
|
||||
"images",
|
||||
],
|
||||
"block_names": ["decode"],
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user