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
80b86587
Commit
80b86587
authored
Jun 06, 2022
by
Patrick von Platen
Browse files
up
parent
a9f0785d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
13 deletions
+5
-13
models/vision/ddpm/example.py
models/vision/ddpm/example.py
+1
-11
src/diffusers/pipeline_utils.py
src/diffusers/pipeline_utils.py
+4
-2
No files found.
models/vision/ddpm/example.py
View file @
80b86587
...
...
@@ -2,21 +2,11 @@
import
tempfile
import
sys
from
diffusers
import
GaussianDDPMScheduler
,
UNetModel
from
modeling_ddpm
import
DDPM
model_id
=
sys
.
argv
[
1
]
folder
=
sys
.
argv
[
2
]
save
=
bool
(
int
(
sys
.
argv
[
3
]))
unet
=
UNetModel
.
from_pretrained
(
model_id
)
sampler
=
GaussianDDPMScheduler
.
from_config
(
model_id
)
# compose Diffusion Pipeline
if
save
:
ddpm
=
DDPM
(
unet
,
sampler
)
ddpm
.
save_pretrained
(
folder
)
ddpm
=
DDPM
.
from_pretrained
(
model_id
)
image
=
ddpm
()
import
PIL.Image
...
...
src/diffusers/pipeline_utils.py
View file @
80b86587
...
...
@@ -17,6 +17,7 @@
import
importlib
import
os
from
typing
import
Optional
,
Union
from
huggingface_hub
import
snapshot_download
# CHANGE to diffusers.utils
from
transformers.utils
import
logging
...
...
@@ -82,7 +83,8 @@ class DiffusionPipeline(Config):
@
classmethod
def
from_pretrained
(
cls
,
pretrained_model_name_or_path
:
Optional
[
Union
[
str
,
os
.
PathLike
]],
**
kwargs
):
# use snapshot download here to get it working from from_pretrained
config_dict
,
_
=
cls
.
get_config_dict
(
pretrained_model_name_or_path
)
cached_folder
=
snapshot_download
(
pretrained_model_name_or_path
)
config_dict
,
_
=
cls
.
get_config_dict
(
cached_folder
)
init_kwargs
=
{}
...
...
@@ -100,7 +102,7 @@ class DiffusionPipeline(Config):
load_method
=
getattr
(
class_obj
,
load_method_name
)
loaded_sub_model
=
load_method
(
os
.
path
.
join
(
pretrained_model_name_or_path
,
name
))
loaded_sub_model
=
load_method
(
os
.
path
.
join
(
cached_folder
,
name
))
init_kwargs
[
name
]
=
loaded_sub_model
...
...
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