Views
No views yet
1from diffusers import ModularPipelineBlocks
2
3model_id = "diffusers/custom-block-template"
4local_dir = model_id.split("/")[-1]
5
6blocks = ModularPipelineBlocks.from_pretrained(
7 model_id,
8 trust_remote_code=True,
9 local_dir=local_dir
10)custom-block-template/ locally. Feel free to use a custom local_dirblock.py and implement your custom block:descriptionexpected_components if your block needs modelsinputs with your input parametersintermediate_outputs with your output parameters__call__1from diffusers import ModularPipelineBlocks
2
3blocks = ModularPipelineBlocks.from_pretrained(local_dir, trust_remote_code=True)
4pipeline = blocks.init_pipeline()
5output = pipeline(...) # your inputs herepipeline.save_pretrained(local_dir, repo_id="your-username/your-block-name", push_to_hub=True)metadata={"mellon": "<type>"} to your InputParam/OutputParam definitions, then generate the config:1from diffusers.modular_pipelines.mellon_node_utils import MellonPipelineConfig
2
3mellon_config = MellonPipelineConfig.from_custom_block(blocks)
4mellon_config.save(local_dir, repo_id="your-username/your-block-name", push_to_hub=True)