Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
20c2ab02
Unverified
Commit
20c2ab02
authored
Jun 06, 2022
by
Patrick von Platen
Committed by
GitHub
Jun 06, 2022
Browse files
Update README.md
parent
80b86587
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
README.md
README.md
+8
-18
No files found.
README.md
View file @
20c2ab02
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment