denoising diffusion implicit models
简介
核心亮点
- 大幅提升采样速度,降低生成语音的延迟
- 在减少推理步骤的同时保持高保真度
- 基于 Keras 实现,易于集成到现有工作流
- 适用于实时语音增强与噪声剔除场景
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("keras-io/denoising-diffusion-implicit-models")
tokenizer = AutoTokenizer.from_pretrained("keras-io/denoising-diffusion-implicit-models")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download keras-io/denoising-diffusion-implicit-models
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download keras-io/denoising-diffusion-implicit-models config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('keras-io/denoising-diffusion-implicit-models')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/keras-io/denoising-diffusion-implicit-models
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/keras-io/denoising-diffusion-implicit-models
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('keras-io/denoising-diffusion-implicit-models')
tokenizer = AutoTokenizer.from_pretrained('keras-io/denoising-diffusion-implicit-models')
完整文档
---
library_name: tf-keras
tags:
- generative
- denoising
- diffusion
- ddim
- ddpm
- unconditional-image-generation
---
This model was created for the Keras code example on denoising diffusion implicit models (DDIM).
Model description
The model uses a U-Net with identical input and output dimensions. It progressively downsamples and upsamples its input image, adding skip connections between layers having the same resolution. The architecture is a simplified version of the architecture of DDPM. It consists of convolutional residual blocks and lacks attention layers. The network takes two inputs, the noisy images and the variances of their noise components, which it encodes using sinusoidal embeddings.
Intended uses & limitations
The model is intended for educational purposes, as a simple example of denoising diffusion generative models. It has modest compute requirements with reasonable natural image generation performance.
Training and evaluation data
The model is trained on the Oxford Flowers 102 dataset for generating images, which is a diverse natural dataset containing around 8,000 images of flowers. Since the official splits are imbalanced (most of the images are contained in the test splite), new random splits were created (80% train, 20% validation) for training the model. Center crops were used for preprocessing.
Training procedure
The model is trained to denoise noisy images, and can generate images by iteratively denoising pure Gaussian noise.
For more details check out the Keras code example, or the companion code repository, with additional features..
Training hyperparameters
| Hyperparameters | Value |
| :-- | :-- |
| num epochs | 80 |
| dataset repetitions per epoch| 5 |
| image resolution | 64 |
| min signal rate | 0.02 |
| max signal rate | 0.95 |
| embedding dimensions | 32 |
| embedding max frequency | 1000.0 |
| block widths | 32, 64, 96, 128 |
| block depth | 2 |
| batch size | 64 |
| exponential moving average | 0.999 |
| optimizer | AdamW |
| learning rate | 1e-3 |
| weight decay | 1e-4 |
## Model plot
<details>
<summary>View model plot</summary>
!network architecture residual unet
</details>