Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
20d91782
Commit
20d91782
authored
Jun 12, 2022
by
Patrick von Platen
Browse files
correct readme
parent
7764669c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
README.md
README.md
+13
-5
No files found.
README.md
View file @
20d91782
...
...
@@ -48,7 +48,11 @@ noise_scheduler = GaussianDDPMScheduler.from_config("fusing/ddpm-lsun-church")
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-lsun-church"
).
to
(
torch_device
)
# 2. Sample gaussian noise
image
=
noise_scheduler
.
sample_noise
((
1
,
unet
.
in_channels
,
unet
.
resolution
,
unet
.
resolution
),
device
=
torch_device
,
generator
=
generator
)
image
=
torch
.
randn
(
(
1
,
unet
.
in_channels
,
unet
.
resolution
,
unet
.
resolution
)
generator
=
generator
,
)
image
=
image
.
to
(
torch_device
)
# 3. Denoise
num_prediction_steps
=
len
(
noise_scheduler
)
...
...
@@ -63,7 +67,7 @@ for t in tqdm.tqdm(reversed(range(num_prediction_steps)), total=num_prediction_s
# optionally sample variance
variance
=
0
if
t
>
0
:
noise
=
noise_scheduler
.
sample_noise
(
image
.
shape
,
device
=
image
.
devic
e
,
generator
=
generator
)
noise
=
torch
.
randn
(
image
.
shap
e
,
generator
=
generator
)
.
to
(
image
.
device
)
variance
=
noise_scheduler
.
get_variance
(
t
).
sqrt
()
*
noise
# set current image to prev_image: x_t -> x_t-1
...
...
@@ -96,7 +100,11 @@ noise_scheduler = DDIMScheduler.from_config("fusing/ddpm-celeba-hq")
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-celeba-hq"
).
to
(
torch_device
)
# 2. Sample gaussian noise
image
=
noise_scheduler
.
sample_noise
((
1
,
unet
.
in_channels
,
unet
.
resolution
,
unet
.
resolution
),
device
=
torch_device
,
generator
=
generator
)
image
=
torch
.
randn
(
(
1
,
unet
.
in_channels
,
unet
.
resolution
,
unet
.
resolution
)
generator
=
generator
,
)
image
=
image
.
to
(
torch_device
)
# 3. Denoise
num_inference_steps
=
50
...
...
@@ -114,7 +122,7 @@ for t in tqdm.tqdm(reversed(range(num_inference_steps)), total=num_inference_ste
# 3. optionally sample variance
variance
=
0
if
eta
>
0
:
noise
=
noise_scheduler
.
sample_noise
(
image
.
shape
,
device
=
image
.
devic
e
,
generator
=
generator
)
noise
=
torch
.
randn
(
image
.
shap
e
,
generator
=
generator
)
.
to
(
image
.
device
)
variance
=
noise_scheduler
.
get_variance
(
t
).
sqrt
()
*
eta
*
noise
# 4. set current image to prev_image: x_t -> x_t-1
...
...
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