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
20d91782
"git@developer.sourcefind.cn:change/sglang.git" did not exist on "d052f4c8a9fb7e135ca0f0b09f6feead93db9e01"
Commit
20d91782
authored
Jun 12, 2022
by
Patrick von Platen
Browse files
correct readme
parent
7764669c
Changes
1
Hide 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,9 +48,13 @@ noise_scheduler = GaussianDDPMScheduler.from_config("fusing/ddpm-lsun-church")
...
@@ -48,9 +48,13 @@ noise_scheduler = GaussianDDPMScheduler.from_config("fusing/ddpm-lsun-church")
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-lsun-church"
).
to
(
torch_device
)
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-lsun-church"
).
to
(
torch_device
)
# 2. Sample gaussian noise
# 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
# 3. Denoise
num_prediction_steps
=
len
(
noise_scheduler
)
num_prediction_steps
=
len
(
noise_scheduler
)
for
t
in
tqdm
.
tqdm
(
reversed
(
range
(
num_prediction_steps
)),
total
=
num_prediction_steps
):
for
t
in
tqdm
.
tqdm
(
reversed
(
range
(
num_prediction_steps
)),
total
=
num_prediction_steps
):
# predict noise residual
# predict noise residual
...
@@ -63,7 +67,7 @@ for t in tqdm.tqdm(reversed(range(num_prediction_steps)), total=num_prediction_s
...
@@ -63,7 +67,7 @@ for t in tqdm.tqdm(reversed(range(num_prediction_steps)), total=num_prediction_s
# optionally sample variance
# optionally sample variance
variance
=
0
variance
=
0
if
t
>
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
variance
=
noise_scheduler
.
get_variance
(
t
).
sqrt
()
*
noise
# set current image to prev_image: x_t -> x_t-1
# set current image to prev_image: x_t -> x_t-1
...
@@ -96,7 +100,11 @@ noise_scheduler = DDIMScheduler.from_config("fusing/ddpm-celeba-hq")
...
@@ -96,7 +100,11 @@ noise_scheduler = DDIMScheduler.from_config("fusing/ddpm-celeba-hq")
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-celeba-hq"
).
to
(
torch_device
)
unet
=
UNetModel
.
from_pretrained
(
"fusing/ddpm-celeba-hq"
).
to
(
torch_device
)
# 2. Sample gaussian noise
# 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
# 3. Denoise
num_inference_steps
=
50
num_inference_steps
=
50
...
@@ -114,7 +122,7 @@ for t in tqdm.tqdm(reversed(range(num_inference_steps)), total=num_inference_ste
...
@@ -114,7 +122,7 @@ for t in tqdm.tqdm(reversed(range(num_inference_steps)), total=num_inference_ste
# 3. optionally sample variance
# 3. optionally sample variance
variance
=
0
variance
=
0
if
eta
>
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
variance
=
noise_scheduler
.
get_variance
(
t
).
sqrt
()
*
eta
*
noise
# 4. set current image to prev_image: x_t -> x_t-1
# 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