KerasHub: Pretrained Models / API documentation / Model Architectures / Flux / FluxTextToImagePreprocessor layer

FluxTextToImagePreprocessor layer

[source]

FluxTextToImagePreprocessor class

keras_hub.models.FluxTextToImagePreprocessor(
    clip_l_preprocessor, t5_preprocessor=None, **kwargs
)

Flux text-to-image model preprocessor.

This preprocessing layer is meant for use with keras_hub.models.FluxTextToImagePreprocessor.

For use with generation, the layer exposes one methods generate_preprocess().

Arguments


[source]

from_preset method

FluxTextToImagePreprocessor.from_preset(
    preset, config_file="preprocessor.json", **kwargs
)

Instantiate a keras_hub.models.Preprocessor from a model preset.

A preset is a directory of configs, weights and other file assets used to save and load a pre-trained model. The preset can be passed as one of:

  1. a built-in preset identifier like 'bert_base_en'
  2. a Kaggle Models handle like 'kaggle://user/bert/keras/bert_base_en'
  3. a Hugging Face handle like 'hf://user/bert_base_en'
  4. a path to a local preset directory like './bert_base_en'

For any Preprocessor subclass, you can run cls.presets.keys() to list all built-in presets available on the class.

As there are usually multiple preprocessing classes for a given model, this method should be called on a specific subclass like keras_hub.models.BertTextClassifierPreprocessor.from_preset().

Arguments

  • preset: string. A built-in preset identifier, a Kaggle Models handle, a Hugging Face handle, or a path to a local directory.

Examples

# Load a preprocessor for Gemma generation.
preprocessor = keras_hub.models.CausalLMPreprocessor.from_preset(
    "gemma_2b_en",
)

# Load a preprocessor for Bert classification.
preprocessor = keras_hub.models.TextClassifierPreprocessor.from_preset(
    "bert_base_en",
)