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
186689af
Unverified
Commit
186689af
authored
Mar 08, 2023
by
Víctor Martínez
Committed by
GitHub
Mar 08, 2023
Browse files
fix: un-existing tmp config file in linux, avoid unnecessary disk IO (#2591)
parent
cbbad0af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
27 deletions
+18
-27
src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
...diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
+18
-27
No files found.
src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
View file @
186689af
...
...
@@ -14,9 +14,8 @@
# limitations under the License.
""" Conversion script for the Stable Diffusion checkpoints."""
import
os
import
re
import
tempfile
from
io
import
BytesIO
from
typing
import
Optional
import
requests
...
...
@@ -1046,29 +1045,21 @@ def load_pipeline_from_original_stable_diffusion_ckpt(
if
"state_dict"
in
checkpoint
:
checkpoint
=
checkpoint
[
"state_dict"
]
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
if
original_config_file
is
None
:
key_name
=
"model.diffusion_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight"
original_config_file
=
os
.
path
.
join
(
tmpdir
,
"inference.yaml"
)
# model_type = "v1"
config_url
=
"https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
if
key_name
in
checkpoint
and
checkpoint
[
key_name
].
shape
[
-
1
]
==
1024
:
if
not
os
.
path
.
isfile
(
"v2-inference-v.yaml"
):
# model_type = "v2"
r
=
requests
.
get
(
" https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml"
)
open
(
original_config_file
,
"wb"
).
write
(
r
.
content
)
config_url
=
"https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml"
if
global_step
==
110000
:
# v2.1 needs to upcast attention
upcast_attention
=
True
else
:
if
not
os
.
path
.
isfile
(
"v1-inference.yaml"
):
# model_type = "v1"
r
=
requests
.
get
(
" https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
)
open
(
original_config_file
,
"wb"
).
write
(
r
.
content
)
original_config_file
=
BytesIO
(
requests
.
get
(
config_url
).
content
)
original_config
=
OmegaConf
.
load
(
original_config_file
)
...
...
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