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
383dc795
Commit
383dc795
authored
Jun 08, 2022
by
anton-l
Browse files
glide is alive!
parent
d754ce5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
models/vision/glide/modeling_glide.py
models/vision/glide/modeling_glide.py
+3
-0
models/vision/glide/run_glide.py
models/vision/glide/run_glide.py
+7
-1
No files found.
models/vision/glide/modeling_glide.py
View file @
383dc795
...
...
@@ -124,6 +124,7 @@ class GLIDE(DiffusionPipeline):
-
_extract_into_tensor
(
self
.
noise_scheduler
.
sqrt_recipm1_alphas_cumprod
,
t
,
x_t
.
shape
)
*
eps
)
@
torch
.
no_grad
()
def
__call__
(
self
,
prompt
,
generator
=
None
,
torch_device
=
None
):
torch_device
=
"cuda"
if
torch
.
cuda
.
is_available
()
else
"cpu"
...
...
@@ -164,4 +165,6 @@ class GLIDE(DiffusionPipeline):
nonzero_mask
=
(
t
!=
0
).
float
().
view
(
-
1
,
*
([
1
]
*
(
len
(
image
.
shape
)
-
1
)))
# no noise when t == 0
image
=
mean
+
nonzero_mask
*
torch
.
exp
(
0.5
*
log_variance
)
*
noise
image
=
image
[
0
].
permute
(
1
,
2
,
0
)
return
image
models/vision/glide/run_glide.py
View file @
383dc795
import
torch
from
modeling_glide
import
GLIDE
import
matplotlib
import
matplotlib.pyplot
as
plt
matplotlib
.
rcParams
[
'interactive'
]
=
True
generator
=
torch
.
Generator
()
...
...
@@ -10,5 +13,8 @@ generator = generator.manual_seed(0)
pipeline
=
GLIDE
.
from_pretrained
(
"fusing/glide-base"
)
img
=
pipeline
(
"an oil painting of a corgi"
,
generator
)
img
=
((
img
+
1
)
*
127.5
).
round
().
clamp
(
0
,
255
).
to
(
torch
.
uint8
).
cpu
().
numpy
()
print
(
img
)
plt
.
figure
(
figsize
=
(
8
,
8
))
plt
.
imshow
(
img
)
plt
.
show
()
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