Update README.md
This commit is contained in:
parent
80b865878c
commit
20c2ab0269
26
README.md
26
README.md
|
@ -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")
|
ddpm = DDPM.from_pretrained("fusing/ddpm-lsun-bedroom-pipe")
|
||||||
sampler = GaussianDDPMScheduler.from_config("fusing/ddpm_dummy")
|
|
||||||
|
|
||||||
# compose Diffusion Pipeline
|
|
||||||
ddpm = DDPM(unet, sampler)
|
|
||||||
# generate / sample
|
|
||||||
image = ddpm()
|
image = ddpm()
|
||||||
print(image)
|
|
||||||
|
|
||||||
|
import PIL.Image
|
||||||
# save and load with 0 extra code (handled by general `DiffusionPipeline` class)
|
import numpy as np
|
||||||
# will also be possible to do so from the Hub
|
image_processed = image.cpu().permute(0, 2, 3, 1)
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
image_processed = (image_processed + 1.0) * 127.5
|
||||||
ddpm.save_pretrained(tmpdirname)
|
image_processed = image_processed.numpy().astype(np.uint8)
|
||||||
print("Model saved")
|
image_pil = PIL.Image.fromarray(image_processed[0])
|
||||||
ddpm_new = DDPM.from_pretrained(tmpdirname)
|
image_pil.save("test.png")
|
||||||
print("Model loaded")
|
|
||||||
print(ddpm_new)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Library structure:
|
## Library structure:
|
||||||
|
|
Loading…
Reference in New Issue