FluxBackbone
classkeras_hub.models.FluxBackbone(
input_channels,
hidden_size,
mlp_ratio,
num_heads,
depth,
depth_single_blocks,
axes_dim,
theta,
use_bias,
guidance_embed=False,
image_shape=(None, 768, 3072),
text_shape=(None, 768, 3072),
image_ids_shape=(None, 768, 3072),
text_ids_shape=(None, 768, 3072),
y_shape=(None, 128),
**kwargs
)
Transformer model for flow matching on sequences.
The model processes image and text data with associated positional and timestep embeddings, and optionally applies guidance embedding. Double-stream blocks handle separate image and text streams, while single-stream blocks combine these streams. Ported from: https://github.com/black-forest-labs/flux
Arguments
num_heads
.Call arguments
Raises
hidden_size
is not divisible by num_heads
, or if
sum(axes_dim)
is not equal to the positional embedding dimension.from_preset
methodFluxBackbone.from_preset(preset, load_weights=True, **kwargs)
Instantiate a keras_hub.models.Backbone
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 a
one of:
'bert_base_en'
'kaggle://user/bert/keras/bert_base_en'
'hf://user/bert_base_en'
'./bert_base_en'
This constructor can be called in one of two ways. Either from the base
class like keras_hub.models.Backbone.from_preset()
, or from
a model class like keras_hub.models.GemmaBackbone.from_preset()
.
If calling from the base class, the subclass of the returning object
will be inferred from the config in the preset directory.
For any Backbone
subclass, you can run cls.presets.keys()
to list
all built-in presets available on the class.
Arguments
True
, the weights will be loaded into the
model architecture. If False
, the weights will be randomly
initialized.Examples
# Load a Gemma backbone with pre-trained weights.
model = keras_hub.models.Backbone.from_preset(
"gemma_2b_en",
)
# Load a Bert backbone with a pre-trained config and random weights.
model = keras_hub.models.Backbone.from_preset(
"bert_base_en",
load_weights=False,
)