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
c6a33e3d
Commit
c6a33e3d
authored
Jun 09, 2022
by
anton-l
Browse files
fix tokenizers pipeline
parent
dc6324d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
models/vision/glide/run_glide.py
models/vision/glide/run_glide.py
+13
-11
src/diffusers/pipeline_utils.py
src/diffusers/pipeline_utils.py
+1
-1
No files found.
models/vision/glide/run_glide.py
View file @
c6a33e3d
import
torch
import
torch
from
diffusers
import
DiffusionPipeline
from
modeling_glide
import
GLIDE
import
PIL.Image
import
matplotlib
import
matplotlib.pyplot
as
plt
matplotlib
.
rcParams
[
'interactive'
]
=
True
generator
=
torch
.
Generator
()
generator
=
torch
.
Generator
()
generator
=
generator
.
manual_seed
(
0
)
generator
=
generator
.
manual_seed
(
0
)
pipeline
=
GLIDE
.
from_pretrained
(
"fusing/glide-base"
)
model_id
=
"fusing/glide-base"
# load model and scheduler
pipeline
=
DiffusionPipeline
.
from_pretrained
(
model_id
)
# run inference (text-conditioned denoising + upscaling)
img
=
pipeline
(
"a clip art of a hugging face"
,
generator
)
img
=
pipeline
(
"a pencil sketch of a corgi"
,
generator
)
# process image to PIL
img
=
((
img
+
1
)
*
127.5
).
round
().
clamp
(
0
,
255
).
to
(
torch
.
uint8
).
cpu
().
numpy
()
img
=
((
img
+
1
)
*
127.5
).
round
().
clamp
(
0
,
255
).
to
(
torch
.
uint8
).
cpu
().
numpy
()
image_pil
=
PIL
.
Image
.
fromarray
(
img
)
plt
.
figure
(
figsize
=
(
8
,
8
))
# save image
plt
.
imshow
(
img
)
image_pil
.
save
(
"test.png"
)
plt
.
show
()
\ No newline at end of file
src/diffusers/pipeline_utils.py
View file @
c6a33e3d
...
@@ -42,7 +42,7 @@ LOADABLE_CLASSES = {
...
@@ -42,7 +42,7 @@ LOADABLE_CLASSES = {
"GlideDDIMScheduler"
:
[
"save_config"
,
"from_config"
],
"GlideDDIMScheduler"
:
[
"save_config"
,
"from_config"
],
},
},
"transformers"
:
{
"transformers"
:
{
"
GPT2
Tokenizer"
:
[
"save_pretrained"
,
"from_pretrained"
],
"
PreTrained
Tokenizer"
:
[
"save_pretrained"
,
"from_pretrained"
],
},
},
}
}
...
...
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