Instructions to use keras/stable_diffusion_3_medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/stable_diffusion_3_medium with KerasHub:
import keras_hub # Load TextToImage model (optional: use half precision for inference) text_to_image = keras_hub.models.TextToImage.from_preset("hf://keras/stable_diffusion_3_medium", dtype="bfloat16") # Generate images with a TextToImage model. text_to_image.generate("Astronaut in a jungle")import keras_hub # Create a ImageToImage model task = keras_hub.models.ImageToImage.from_preset("hf://keras/stable_diffusion_3_medium")import keras_hub # Create a Inpaint model task = keras_hub.models.Inpaint.from_preset("hf://keras/stable_diffusion_3_medium")import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/stable_diffusion_3_medium") - Keras
How to use keras/stable_diffusion_3_medium 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://keras/stable_diffusion_3_medium") - Notebooks
- Google Colab
- Kaggle
Download clip_l_preprocessor.json from keras/stable_diffusion_3_medium: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/keras/stable_diffusion_3_medium/resolve/main/clip_l_preprocessor.json
- Command line
-
hf download hf://keras/stable_diffusion_3_medium/clip_l_preprocessor.json
-
curl -L -o clip_l_preprocessor.json https://huggingface.co/keras/stable_diffusion_3_medium/resolve/main/clip_l_preprocessor.json
1.4 kB
| { | |
| "module": "keras_hub.src.models.clip.clip_preprocessor", | |
| "class_name": "CLIPPreprocessor", | |
| "config": { | |
| "name": "clip_l_preprocessor", | |
| "trainable": true, | |
| "dtype": { | |
| "module": "keras", | |
| "class_name": "DTypePolicy", | |
| "config": { | |
| "name": "float16" | |
| }, | |
| "registered_name": null | |
| }, | |
| "tokenizer": { | |
| "module": "keras_hub.src.models.clip.clip_tokenizer", | |
| "class_name": "CLIPTokenizer", | |
| "config": { | |
| "name": "clip_l_tokenizer", | |
| "trainable": true, | |
| "dtype": { | |
| "module": "keras", | |
| "class_name": "DTypePolicy", | |
| "config": { | |
| "name": "int32" | |
| }, | |
| "registered_name": null | |
| }, | |
| "config_file": "clip_l_tokenizer.json", | |
| "sequence_length": null, | |
| "add_prefix_space": false, | |
| "pad_with_end_token": true | |
| }, | |
| "registered_name": "keras_hub>CLIPTokenizer" | |
| }, | |
| "config_file": "clip_l_preprocessor.json", | |
| "sequence_length": 77, | |
| "add_start_token": true, | |
| "add_end_token": true, | |
| "to_lower": true | |
| }, | |
| "registered_name": "keras_hub>CLIPPreprocessor" | |
| } |