| | from models.text_diffusion_pipeline import TextConditionalDDPMPipeline
|
| | from models.latent_diffusion_pipeline import UnconditionalDDPMPipeline
|
| | import os
|
| | from diffusers.pipelines.pipeline_utils import DiffusionPipeline
|
| |
|
| |
|
| | def get_pipeline(model_path):
|
| |
|
| | if os.path.isdir(model_path):
|
| |
|
| | if os.path.exists(os.path.join(model_path, "unet")):
|
| | if os.path.exists(os.path.join(model_path, "text_encoder")):
|
| |
|
| | pipe = TextConditionalDDPMPipeline.from_pretrained(model_path)
|
| | else:
|
| |
|
| | pipe = UnconditionalDDPMPipeline.from_pretrained(model_path)
|
| | else:
|
| |
|
| |
|
| | print(model_path)
|
| | config, _ = DiffusionPipeline.load_config(model_path)
|
| | has_text_encoder = "text_encoder" in config
|
| |
|
| | if has_text_encoder:
|
| |
|
| | pipe = DiffusionPipeline.from_pretrained(
|
| | model_path,
|
| | custom_pipeline="models.text_diffusion_pipeline.TextConditionalDDPMPipeline",
|
| | trust_remote_code=True,
|
| | )
|
| | else:
|
| |
|
| | pipe = DiffusionPipeline.from_pretrained(
|
| | model_path,
|
| | custom_pipeline="models.latent_diffusion_pipeline.UnconditionalDDPMPipeline",
|
| | trust_remote_code=True,
|
| | )
|
| |
|
| | return pipe |