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
ac4c695d
Unverified
Commit
ac4c695d
authored
Nov 08, 2022
by
Duong A. Nguyen
Committed by
GitHub
Nov 07, 2022
Browse files
[Flax examples] Load text encoder from subfolder (#1147)
load text encoder from subfolder
parent
01733238
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
3 deletions
+7
-3
examples/dreambooth/train_dreambooth_flax.py
examples/dreambooth/train_dreambooth_flax.py
+3
-1
examples/text_to_image/train_text_to_image_flax.py
examples/text_to_image/train_text_to_image_flax.py
+3
-1
examples/textual_inversion/textual_inversion_flax.py
examples/textual_inversion/textual_inversion_flax.py
+1
-1
No files found.
examples/dreambooth/train_dreambooth_flax.py
View file @
ac4c695d
...
@@ -452,7 +452,9 @@ def main():
...
@@ -452,7 +452,9 @@ def main():
weight_dtype
=
jnp
.
bfloat16
weight_dtype
=
jnp
.
bfloat16
# Load models and create wrapper for stable diffusion
# Load models and create wrapper for stable diffusion
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
"openai/clip-vit-large-patch14"
,
dtype
=
weight_dtype
)
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"text_encoder"
,
dtype
=
weight_dtype
)
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
,
dtype
=
weight_dtype
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
,
dtype
=
weight_dtype
)
)
...
...
examples/text_to_image/train_text_to_image_flax.py
View file @
ac4c695d
...
@@ -379,7 +379,9 @@ def main():
...
@@ -379,7 +379,9 @@ def main():
# Load models and create wrapper for stable diffusion
# Load models and create wrapper for stable diffusion
tokenizer
=
CLIPTokenizer
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"tokenizer"
)
tokenizer
=
CLIPTokenizer
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"tokenizer"
)
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
"openai/clip-vit-large-patch14"
,
dtype
=
weight_dtype
)
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"text_encoder"
,
dtype
=
weight_dtype
)
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
,
dtype
=
weight_dtype
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
,
dtype
=
weight_dtype
)
)
...
...
examples/textual_inversion/textual_inversion_flax.py
View file @
ac4c695d
...
@@ -391,7 +391,7 @@ def main():
...
@@ -391,7 +391,7 @@ def main():
placeholder_token_id
=
tokenizer
.
convert_tokens_to_ids
(
args
.
placeholder_token
)
placeholder_token_id
=
tokenizer
.
convert_tokens_to_ids
(
args
.
placeholder_token
)
# Load models and create wrapper for stable diffusion
# Load models and create wrapper for stable diffusion
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
"openai/clip-vit-large-patch14
"
)
text_encoder
=
FlaxCLIPTextModel
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"text_encoder
"
)
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
)
vae
,
vae_params
=
FlaxAutoencoderKL
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"vae"
)
unet
,
unet_params
=
FlaxUNet2DConditionModel
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"unet"
)
unet
,
unet_params
=
FlaxUNet2DConditionModel
.
from_pretrained
(
args
.
pretrained_model_name_or_path
,
subfolder
=
"unet"
)
...
...
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