Text-to-Image
ZeroModels
Keras
PyTorch
JAX
TensorFlow
English
stable-diffusion
stable-diffusion-diffusers
diffusion
latent-diffusion
Instructions to use zeromodels/stable-diffusion-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/stable-diffusion-2 with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/stable-diffusion-2") - Keras
How to use zeromodels/stable-diffusion-2 with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/stable-diffusion-2") - Notebooks
- Google Colab
- Kaggle
Add stable-diffusion-2: zeromodels Keras 3 conversion of sd2-community/stable-diffusion-2
2546b6e verified Download zm_config.json from zeromodels/stable-diffusion-2: direct link, hf CLI and curl.
- Browser
- Download file 2.29 kB
-
https://huggingface.co/zeromodels/stable-diffusion-2/resolve/main/zm_config.json
- Command line
-
hf download hf://zeromodels/stable-diffusion-2/zm_config.json
-
curl -L -o zm_config.json https://huggingface.co/zeromodels/stable-diffusion-2/resolve/main/zm_config.json
2.29 kB
| { | |
| "library_name": "zeromodels", | |
| "zeromodels_version": "1.3.3", | |
| "model_module": "zeromodels.models.stable_diffusion_2", | |
| "model_class": "StableDiffusion2Model", | |
| "variant": "stable-diffusion-2", | |
| "weights": "model.weights.h5", | |
| "schema_version": 2, | |
| "weight_dtype": "float32", | |
| "model_type": "stable_diffusion_2", | |
| "unet_config": { | |
| "sample_size": 96, | |
| "in_channels": 4, | |
| "out_channels": 4, | |
| "down_block_types": [ | |
| "CrossAttnDownBlock2D", | |
| "CrossAttnDownBlock2D", | |
| "CrossAttnDownBlock2D", | |
| "DownBlock2D" | |
| ], | |
| "up_block_types": [ | |
| "UpBlock2D", | |
| "CrossAttnUpBlock2D", | |
| "CrossAttnUpBlock2D", | |
| "CrossAttnUpBlock2D" | |
| ], | |
| "block_out_channels": [ | |
| 320, | |
| 640, | |
| 1280, | |
| 1280 | |
| ], | |
| "layers_per_block": 2, | |
| "cross_attention_dim": 1024, | |
| "num_attention_heads": [ | |
| 5, | |
| 10, | |
| 20, | |
| 20 | |
| ], | |
| "norm_num_groups": 32, | |
| "use_linear_projection": true, | |
| "transformer_layers_per_block": 1, | |
| "addition_embed_type": null, | |
| "addition_time_embed_dim": 256, | |
| "projection_class_embeddings_input_dim": null, | |
| "num_time_ids": 6, | |
| "text_seq_len": 77 | |
| }, | |
| "vae_config": { | |
| "in_channels": 3, | |
| "out_channels": 3, | |
| "latent_channels": 4, | |
| "block_out_channels": [ | |
| 128, | |
| 256, | |
| 512, | |
| 512 | |
| ], | |
| "layers_per_block": 2, | |
| "norm_num_groups": 32, | |
| "sample_size": 768, | |
| "scaling_factor": 0.18215, | |
| "force_upcast": false, | |
| "shift_factor": 0.0, | |
| "use_quant_conv": true, | |
| "use_post_quant_conv": true | |
| }, | |
| "text_config": { | |
| "hidden_dim": 1024, | |
| "num_heads": 16, | |
| "num_layers": 23, | |
| "mlp_ratio": 4.0, | |
| "vocab_size": 49408, | |
| "max_seq_len": 77 | |
| }, | |
| "hidden_act": "gelu", | |
| "layer_norm_eps": 1e-05, | |
| "bos_token_id": 49406, | |
| "eos_token_id": 49407, | |
| "pad_token_id": 0, | |
| "scheduler_config": { | |
| "_class_name": "DDIMScheduler", | |
| "beta_end": 0.012, | |
| "beta_schedule": "scaled_linear", | |
| "beta_start": 0.00085, | |
| "clip_sample": false, | |
| "num_train_timesteps": 1000, | |
| "prediction_type": "v_prediction", | |
| "set_alpha_to_one": false, | |
| "skip_prk_steps": true, | |
| "steps_offset": 1, | |
| "trained_betas": null | |
| }, | |
| "generate_args": { | |
| "num_inference_steps": 50, | |
| "guidance_scale": 7.5 | |
| } | |
| } |