Unverified Commit 20c2ab02 authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

Update README.md

parent 80b86587
...@@ -80,28 +80,18 @@ image_pil.save("test.png") ...@@ -80,28 +80,18 @@ image_pil.save("test.png")
Example: Example:
```python ```python
from diffusers import UNetModel, GaussianDDPMScheduler
from modeling_ddpm import DDPM from modeling_ddpm import DDPM
import tempfile
unet = UNetModel.from_pretrained("fusing/ddpm_dummy")
sampler = GaussianDDPMScheduler.from_config("fusing/ddpm_dummy")
# compose Diffusion Pipeline ddpm = DDPM.from_pretrained("fusing/ddpm-lsun-bedroom-pipe")
ddpm = DDPM(unet, sampler)
# generate / sample
image = ddpm() image = ddpm()
print(image)
# save and load with 0 extra code (handled by general `DiffusionPipeline` class) import PIL.Image
# will also be possible to do so from the Hub import numpy as np
with tempfile.TemporaryDirectory() as tmpdirname: image_processed = image.cpu().permute(0, 2, 3, 1)
ddpm.save_pretrained(tmpdirname) image_processed = (image_processed + 1.0) * 127.5
print("Model saved") image_processed = image_processed.numpy().astype(np.uint8)
ddpm_new = DDPM.from_pretrained(tmpdirname) image_pil = PIL.Image.fromarray(image_processed[0])
print("Model loaded") image_pil.save("test.png")
print(ddpm_new)
``` ```
## Library structure: ## Library structure:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment