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
OpenDAS
diffusers
Commits
edf22c05
Unverified
Commit
edf22c05
authored
Nov 28, 2022
by
Anton Lozhkov
Committed by
GitHub
Nov 28, 2022
Browse files
Hotfix for AttributeErrors in OnnxStableDiffusionInpaintPipelineLegacy (#1448)
parent
5755d168
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
24 deletions
+3
-24
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint_legacy.py
...iffusion/pipeline_onnx_stable_diffusion_inpaint_legacy.py
+3
-24
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint_legacy.py
View file @
edf22c05
...
@@ -5,7 +5,6 @@ import numpy as np
...
@@ -5,7 +5,6 @@ import numpy as np
import
torch
import
torch
import
PIL
import
PIL
from
packaging
import
version
from
transformers
import
CLIPFeatureExtractor
,
CLIPTokenizer
from
transformers
import
CLIPFeatureExtractor
,
CLIPTokenizer
from
...configuration_utils
import
FrozenDict
from
...configuration_utils
import
FrozenDict
...
@@ -68,6 +67,8 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
...
@@ -68,6 +67,8 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
feature_extractor ([`CLIPFeatureExtractor`]):
feature_extractor ([`CLIPFeatureExtractor`]):
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
"""
"""
_optional_components
=
[
"safety_checker"
,
"feature_extractor"
]
vae_encoder
:
OnnxRuntimeModel
vae_encoder
:
OnnxRuntimeModel
vae_decoder
:
OnnxRuntimeModel
vae_decoder
:
OnnxRuntimeModel
text_encoder
:
OnnxRuntimeModel
text_encoder
:
OnnxRuntimeModel
...
@@ -134,27 +135,6 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
...
@@ -134,27 +135,6 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
" checker. If you do not want to use the safety checker, you can pass `'safety_checker=None'` instead."
" checker. If you do not want to use the safety checker, you can pass `'safety_checker=None'` instead."
)
)
is_unet_version_less_0_9_0
=
hasattr
(
unet
.
config
,
"_diffusers_version"
)
and
version
.
parse
(
version
.
parse
(
unet
.
config
.
_diffusers_version
).
base_version
)
<
version
.
parse
(
"0.9.0.dev0"
)
is_unet_sample_size_less_64
=
hasattr
(
unet
.
config
,
"sample_size"
)
and
unet
.
config
.
sample_size
<
64
if
is_unet_version_less_0_9_0
and
is_unet_sample_size_less_64
:
deprecation_message
=
(
"The configuration file of the unet has set the default `sample_size` to smaller than"
" 64 which seems highly unlikely .If you're checkpoint is a fine-tuned version of any of the"
" following:
\n
- CompVis/stable-diffusion-v1-4
\n
- CompVis/stable-diffusion-v1-3
\n
-"
" CompVis/stable-diffusion-v1-2
\n
- CompVis/stable-diffusion-v1-1
\n
- runwayml/stable-diffusion-v1-5"
"
\n
- runwayml/stable-diffusion-inpainting
\n
you should change 'sample_size' to 64 in the"
" configuration file. Please make sure to update the config accordingly as leaving `sample_size=32`"
" in the config might lead to incorrect results in future versions. If you have downloaded this"
" checkpoint from the Hugging Face Hub, it would be very nice if you could open a Pull request for"
" the `unet/config.json` file"
)
deprecate
(
"sample_size<64"
,
"1.0.0"
,
deprecation_message
,
standard_warn
=
False
)
new_config
=
dict
(
unet
.
config
)
new_config
[
"sample_size"
]
=
64
unet
.
_internal_dict
=
FrozenDict
(
new_config
)
self
.
register_modules
(
self
.
register_modules
(
vae_encoder
=
vae_encoder
,
vae_encoder
=
vae_encoder
,
vae_decoder
=
vae_decoder
,
vae_decoder
=
vae_decoder
,
...
@@ -165,7 +145,6 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
...
@@ -165,7 +145,6 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
safety_checker
=
safety_checker
,
safety_checker
=
safety_checker
,
feature_extractor
=
feature_extractor
,
feature_extractor
=
feature_extractor
,
)
)
self
.
vae_scale_factor
=
2
**
(
len
(
self
.
vae
.
config
.
block_out_channels
)
-
1
)
self
.
register_to_config
(
requires_safety_checker
=
requires_safety_checker
)
self
.
register_to_config
(
requires_safety_checker
=
requires_safety_checker
)
# Copied from diffusers.pipelines.stable_diffusion.pipeline_onnx_stable_diffusion.OnnxStableDiffusionPipeline._encode_prompt
# Copied from diffusers.pipelines.stable_diffusion.pipeline_onnx_stable_diffusion.OnnxStableDiffusionPipeline._encode_prompt
...
@@ -372,7 +351,7 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
...
@@ -372,7 +351,7 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
# preprocess mask
# preprocess mask
if
not
isinstance
(
mask_image
,
np
.
ndarray
):
if
not
isinstance
(
mask_image
,
np
.
ndarray
):
mask_image
=
preprocess_mask
(
mask_image
,
self
.
vae_scale_factor
)
mask_image
=
preprocess_mask
(
mask_image
,
8
)
mask_image
=
mask_image
.
astype
(
latents_dtype
)
mask_image
=
mask_image
.
astype
(
latents_dtype
)
mask
=
np
.
concatenate
([
mask_image
]
*
num_images_per_prompt
,
axis
=
0
)
mask
=
np
.
concatenate
([
mask_image
]
*
num_images_per_prompt
,
axis
=
0
)
...
...
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