mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Merge branch 'main' of https://github.com/huggingface/diffusers
This commit is contained in:
86
README.md
86
README.md
@@ -58,12 +58,14 @@ git clone https://github.com/huggingface/diffusers.git
|
||||
cd diffusers && pip install -e .
|
||||
```
|
||||
|
||||
### 1. `diffusers` as a central modular diffusion and sampler library
|
||||
### 1. `diffusers` as a toolbox for schedulers and models.
|
||||
|
||||
`diffusers` is more modularized than `transformers`. The idea is that researchers and engineers can use only parts of the library easily for the own use cases.
|
||||
It could become a central place for all kinds of models, schedulers, training utils and processors that one can mix and match for one's own use case.
|
||||
Both models and schedulers should be load- and saveable from the Hub.
|
||||
|
||||
For more examples see [schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers) and [models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models)
|
||||
|
||||
#### **Example for [DDPM](https://arxiv.org/abs/2006.11239):**
|
||||
|
||||
```python
|
||||
@@ -171,25 +173,35 @@ image_pil = PIL.Image.fromarray(image_processed[0])
|
||||
image_pil.save("test.png")
|
||||
```
|
||||
|
||||
### 2. `diffusers` as a collection of most important Diffusion systems (GLIDE, Dalle, ...)
|
||||
`models` directory in repository hosts the complete code necessary for running a diffusion system as well as to train it. A `DiffusionPipeline` class allows to easily run the diffusion model in inference:
|
||||
### 2. `diffusers` as a collection of popula Diffusion systems (GLIDE, Dalle, ...)
|
||||
|
||||
#### **Example image generation with DDPM**
|
||||
For more examples see [pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines).
|
||||
|
||||
#### **Example image generation with PNDM**
|
||||
|
||||
```python
|
||||
from diffusers import DiffusionPipeline
|
||||
from diffusers import PNDM, UNetModel, PNDMScheduler
|
||||
import PIL.Image
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
model_id = "fusing/ddim-celeba-hq"
|
||||
|
||||
model = UNetModel.from_pretrained(model_id)
|
||||
scheduler = PNDMScheduler()
|
||||
|
||||
# load model and scheduler
|
||||
ddpm = DiffusionPipeline.from_pretrained("fusing/ddpm-lsun-bedroom")
|
||||
ddpm = PNDM(unet=model, noise_scheduler=scheduler)
|
||||
|
||||
# run pipeline in inference (sample random noise and denoise)
|
||||
image = ddpm()
|
||||
with torch.no_grad():
|
||||
image = ddpm()
|
||||
|
||||
# process image to PIL
|
||||
image_processed = image.cpu().permute(0, 2, 3, 1)
|
||||
image_processed = (image_processed + 1.0) * 127.5
|
||||
image_processed = (image_processed + 1.0) / 2
|
||||
image_processed = torch.clamp(image_processed, 0.0, 1.0)
|
||||
image_processed = image_processed * 255
|
||||
image_processed = image_processed.numpy().astype(np.uint8)
|
||||
image_pil = PIL.Image.fromarray(image_processed[0])
|
||||
|
||||
@@ -255,61 +267,3 @@ from scipy.io.wavfile import write as wavwrite
|
||||
sampling_rate = 22050
|
||||
wavwrite("generated_audio.wav", sampling_rate, audio.squeeze().cpu().numpy())
|
||||
```
|
||||
|
||||
## Library structure:
|
||||
|
||||
```
|
||||
βββ LICENSE
|
||||
βββ Makefile
|
||||
βββ README.md
|
||||
βββ pyproject.toml
|
||||
βββ setup.cfg
|
||||
βββ setup.py
|
||||
βββ src
|
||||
β βββ diffusers
|
||||
β βββ __init__.py
|
||||
β βββ configuration_utils.py
|
||||
β βββ dependency_versions_check.py
|
||||
β βββ dependency_versions_table.py
|
||||
β βββ dynamic_modules_utils.py
|
||||
β βββ modeling_utils.py
|
||||
β βββ models
|
||||
β β βββ __init__.py
|
||||
β β βββ unet.py
|
||||
β β βββ unet_glide.py
|
||||
β β βββ unet_ldm.py
|
||||
β βββ pipeline_utils.py
|
||||
β βββ pipelines
|
||||
β β βββ __init__.py
|
||||
β β βββ configuration_ldmbert.py
|
||||
β β βββ conversion_glide.py
|
||||
β β βββ modeling_vae.py
|
||||
β β βββ pipeline_bddm.py
|
||||
β β βββ pipeline_ddim.py
|
||||
β β βββ pipeline_ddpm.py
|
||||
β β βββ pipeline_glide.py
|
||||
β β βββ pipeline_latent_diffusion.py
|
||||
β βββ schedulers
|
||||
β β βββ __init__.py
|
||||
β β βββ classifier_free_guidance.py
|
||||
β β βββ scheduling_ddim.py
|
||||
β β βββ scheduling_ddpm.py
|
||||
β β βββ scheduling_plms.py
|
||||
β β βββ scheduling_utils.py
|
||||
β βββ testing_utils.py
|
||||
β βββ utils
|
||||
β βββ __init__.py
|
||||
β βββ logging.py
|
||||
βββ tests
|
||||
β βββ __init__.py
|
||||
β βββ test_modeling_utils.py
|
||||
β βββ test_scheduler.py
|
||||
βββ utils
|
||||
βββ check_config_docstrings.py
|
||||
βββ check_copies.py
|
||||
βββ check_dummies.py
|
||||
βββ check_inits.py
|
||||
βββ check_repo.py
|
||||
βββ check_table.py
|
||||
βββ check_tf_ops.py
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user