diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-08-29 09:00:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 09:00:04 +0100 |
commit | 33c23c19b6f4821c00a47758f7841baf52ba9081 (patch) | |
tree | 71ad06837519d92a52d6a0021887bf1db4e29360 /candle-examples/examples/stable-diffusion/clip.rs | |
parent | 49326fb9252b67d1e46c69565da93106ee4b71a0 (diff) | |
download | candle-33c23c19b6f4821c00a47758f7841baf52ba9081.tar.gz candle-33c23c19b6f4821c00a47758f7841baf52ba9081.tar.bz2 candle-33c23c19b6f4821c00a47758f7841baf52ba9081.zip |
Preliminary support for SDXL. (#647)
* Preliminary support for SDXL.
* More SDXL support.
* More SDXL.
* Use the proper clip config.
* Querying for existing tensors.
* More robust test.
Diffstat (limited to 'candle-examples/examples/stable-diffusion/clip.rs')
-rw-r--r-- | candle-examples/examples/stable-diffusion/clip.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/candle-examples/examples/stable-diffusion/clip.rs b/candle-examples/examples/stable-diffusion/clip.rs index 2927a404..d26c1c46 100644 --- a/candle-examples/examples/stable-diffusion/clip.rs +++ b/candle-examples/examples/stable-diffusion/clip.rs @@ -69,6 +69,36 @@ impl Config { activation: Activation::Gelu, } } + + // https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/text_encoder/config.json + pub fn sdxl() -> Self { + Self { + vocab_size: 49408, + embed_dim: 768, + intermediate_size: 3072, + max_position_embeddings: 77, + pad_with: Some("!".to_string()), + num_hidden_layers: 12, + num_attention_heads: 12, + projection_dim: 768, + activation: Activation::QuickGelu, + } + } + + // https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/text_encoder_2/config.json + pub fn sdxl2() -> Self { + Self { + vocab_size: 49408, + embed_dim: 1280, + intermediate_size: 5120, + max_position_embeddings: 77, + pad_with: Some("!".to_string()), + num_hidden_layers: 32, + num_attention_heads: 20, + projection_dim: 1280, + activation: Activation::Gelu, + } + } } // CLIP Text Model |