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
fb38bb16
Unverified
Commit
fb38bb16
authored
Oct 27, 2022
by
Anton Lozhkov
Committed by
GitHub
Oct 27, 2022
Browse files
Support grayscale images in `numpy_to_pil` (#1025)
parent
de00c632
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
src/diffusers/pipeline_flax_utils.py
src/diffusers/pipeline_flax_utils.py
+5
-1
src/diffusers/pipeline_utils.py
src/diffusers/pipeline_utils.py
+5
-1
No files found.
src/diffusers/pipeline_flax_utils.py
View file @
fb38bb16
...
...
@@ -444,7 +444,11 @@ class FlaxDiffusionPipeline(ConfigMixin):
if
images
.
ndim
==
3
:
images
=
images
[
None
,
...]
images
=
(
images
*
255
).
round
().
astype
(
"uint8"
)
pil_images
=
[
Image
.
fromarray
(
image
)
for
image
in
images
]
if
images
.
shape
[
-
1
]
==
1
:
# special case for grayscale (single channel) images
pil_images
=
[
Image
.
fromarray
(
image
.
squeeze
(),
mode
=
"L"
)
for
image
in
images
]
else
:
pil_images
=
[
Image
.
fromarray
(
image
)
for
image
in
images
]
return
pil_images
...
...
src/diffusers/pipeline_utils.py
View file @
fb38bb16
...
...
@@ -625,7 +625,11 @@ class DiffusionPipeline(ConfigMixin):
if
images
.
ndim
==
3
:
images
=
images
[
None
,
...]
images
=
(
images
*
255
).
round
().
astype
(
"uint8"
)
pil_images
=
[
Image
.
fromarray
(
image
)
for
image
in
images
]
if
images
.
shape
[
-
1
]
==
1
:
# special case for grayscale (single channel) images
pil_images
=
[
Image
.
fromarray
(
image
.
squeeze
(),
mode
=
"L"
)
for
image
in
images
]
else
:
pil_images
=
[
Image
.
fromarray
(
image
)
for
image
in
images
]
return
pil_images
...
...
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