text
stringlengths 0
5.54k
|
---|
A config dictionary from which the Python class is instantiated. Make sure to only load configuration |
files of compatible classes. return_unused_kwargs (bool, optional, defaults to False) — |
Whether kwargs that are not consumed by the Python class should be returned or not. kwargs (remaining dictionary of keyword arguments, optional) — |
Can be used to update the configuration object (after it is loaded) and initiate the Python class. |
**kwargs are passed directly to the underlying scheduler/model’s __init__ method and eventually |
overwrite the same named arguments in config. Returns |
ModelMixin or SchedulerMixin |
A model or scheduler object instantiated from a config dictionary. |
Instantiate a Python class from a config dictionary. Examples: Copied >>> from diffusers import DDPMScheduler, DDIMScheduler, PNDMScheduler |
>>> # Download scheduler from huggingface.co and cache. |
>>> scheduler = DDPMScheduler.from_pretrained("google/ddpm-cifar10-32") |
>>> # Instantiate DDIM scheduler class with same config as DDPM |
>>> scheduler = DDIMScheduler.from_config(scheduler.config) |
>>> # Instantiate PNDM scheduler class with same config as DDPM |
>>> scheduler = PNDMScheduler.from_config(scheduler.config) save_config < source > ( save_directory: Union push_to_hub: bool = False **kwargs ) Parameters save_directory (str or os.PathLike) — |
Directory where the configuration JSON file is saved (will be created if it does not exist). push_to_hub (bool, optional, defaults to False) — |
Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the |
repository you want to push to with repo_id (will default to the name of save_directory in your |
namespace). kwargs (Dict[str, Any], optional) — |
Additional keyword arguments passed along to the push_to_hub() method. Save a configuration object to the directory specified in save_directory so that it can be reloaded using the |
from_config() class method. to_json_file < source > ( json_file_path: Union ) Parameters json_file_path (str or os.PathLike) — |
Path to the JSON file to save a configuration instance’s parameters. Save the configuration instance’s parameters to a JSON file. to_json_string < source > ( ) → str Returns |
str |
String containing all the attributes that make up the configuration instance in JSON format. |
Serializes the configuration instance to a JSON string. |
Latent Diffusion |
Overview |
Latent Diffusion was proposed in High-Resolution Image Synthesis with Latent Diffusion Models by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer. |
The abstract of the paper is the following: |
By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs. |
The original codebase can be found here. |
Tips: |
Available Pipelines: |
Pipeline |
Tasks |
Colab |
pipeline_latent_diffusion.py |
Text-to-Image Generation |
- |
pipeline_latent_diffusion_superresolution.py |
Super Resolution |
- |
Examples: |
LDMTextToImagePipeline |
class diffusers.LDMTextToImagePipeline |
< |
source |
> |
( |
vqvae: typing.Union[diffusers.models.vq_model.VQModel, diffusers.models.autoencoder_kl.AutoencoderKL] |
bert: PreTrainedModel |
tokenizer: PreTrainedTokenizer |
unet: typing.Union[diffusers.models.unet_2d.UNet2DModel, diffusers.models.unet_2d_condition.UNet2DConditionModel] |
scheduler: typing.Union[diffusers.schedulers.scheduling_ddim.DDIMScheduler, diffusers.schedulers.scheduling_pndm.PNDMScheduler, diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler] |
) |
Parameters |
vqvae (VQModel) — |
Vector-quantized (VQ) Model to encode and decode images to and from latent representations. |
bert (LDMBertModel) — |
Text-encoder model based on BERT architecture. |
tokenizer (transformers.BertTokenizer) — |
Tokenizer of class |
BertTokenizer. |
unet (UNet2DConditionModel) — Conditional U-Net architecture to denoise the encoded image latents. |
scheduler (SchedulerMixin) — |
A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of |
DDIMScheduler, LMSDiscreteScheduler, or PNDMScheduler. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.