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
40dc888f
Commit
40dc888f
authored
Jun 07, 2022
by
Patrick von Platen
Browse files
add first logic for from hub code download
parent
e8ad2b75
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
models/vision/ddpm/modeling_ddpm.py
models/vision/ddpm/modeling_ddpm.py
+3
-0
src/diffusers/pipeline_utils.py
src/diffusers/pipeline_utils.py
+8
-2
No files found.
models/vision/ddpm/modeling_ddpm.py
View file @
40dc888f
...
...
@@ -20,6 +20,9 @@ import torch
class
DDPM
(
DiffusionPipeline
):
modeling_file
=
"modeling_ddpm.py"
def
__init__
(
self
,
unet
,
noise_scheduler
):
super
().
__init__
()
self
.
register_modules
(
unet
=
unet
,
noise_scheduler
=
noise_scheduler
)
...
...
src/diffusers/pipeline_utils.py
View file @
40dc888f
...
...
@@ -53,8 +53,11 @@ class DiffusionPipeline(ConfigMixin):
# retrive class_name
class_name
=
module
.
__class__
.
__name__
register_dict
=
{
name
:
(
library
,
class_name
)}
register_dict
[
"_module"
]
=
self
.
__module__
# save model index config
self
.
register
(
**
{
name
:
(
library
,
class_name
)}
)
self
.
register
(
**
register_dict
)
# set models
setattr
(
self
,
name
,
module
)
...
...
@@ -84,7 +87,10 @@ class DiffusionPipeline(ConfigMixin):
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
cached_folder
=
snapshot_download
(
pretrained_model_name_or_path
)
config_dict
,
_
=
cls
.
get_config_dict
(
cached_folder
)
config_dict
,
pipeline_kwargs
=
cls
.
get_config_dict
(
cached_folder
)
module
=
pipeline_kwargs
[
"_module"
]
# TODO(Suraj) - make from hub import work
init_kwargs
=
{}
...
...
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