MCPcopy Create free account

hub / github.com/black-forest-labs/flux2 / functions

Functions110 in github.com/black-forest-labs/flux2

↓ 10 callersMethod__init__
(self, params: Flux2Params)
src/flux2/model.py:53
↓ 7 callersFunctiontimestep_embedding
Create sinusoidal timestep embeddings. :param t: a 1-D Tensor of N indices, one per batch element. These may be fractio
src/flux2/model.py:710
↓ 6 callersMethod__init__
( self, resolution: int, in_channels: int, ch: int, ch_mult: list[int]
src/flux2/autoencoder.py:109
↓ 5 callersFunctionload_qwen3_embedder
(variant: str, device: str | torch.device = "cuda")
src/flux2/text_encoder.py:435
↓ 4 callersFunctionapply_rope
(xq: Tensor, xk: Tensor, freqs_cis: Tensor)
src/flux2/model.py:828
↓ 4 callersFunctioncausal_attn_fn
Causal attention where reference tokens only attend to themselves. Without cache: layout is [txt, ref, img]. txt+img attend to all, ref self
src/flux2/model.py:758
↓ 4 callersMethodcopy
(self)
scripts/cli.py:43
↓ 4 callersFunctionprint_config
(cfg: Config)
scripts/cli.py:148
↓ 4 callersFunctionswish
(x: Tensor)
src/flux2/autoencoder.py:20
↓ 3 callersMethodencode
(self, x: Tensor)
src/flux2/autoencoder.py:314
↓ 3 callersMethodforward_kv_extract
First denoising step with reference tokens. Runs full forward pass and extracts KV cache for reference tokens to reuse on subsequent
src/flux2/model.py:170
↓ 2 callersMethod_apply_residuals
(self, img, txt, img_attn, txt_attn, mods)
src/flux2/model.py:614
↓ 2 callersFunction_blend_mod_triple
Blend a (shift, scale, gate) triple: first num_ref positions get ref_m, rest get img_m.
src/flux2/model.py:329
↓ 2 callersMethod_out
(self, x: Tensor, attn: Tensor, mlp: Tensor, mod_gate: Tensor)
src/flux2/model.py:482
↓ 2 callersMethod_prepare_qkv
(self, img, txt, pe, pe_ctx, mod_img, mod_txt)
src/flux2/model.py:569
↓ 2 callersMethod_qkv
(self, x: Tensor, mod: tuple[Tensor, Tensor, Tensor])
src/flux2/model.py:468
↓ 2 callersFunctionapply_updates
(cfg: Config, updates: Dict[str, Any])
scripts/cli.py:110
↓ 2 callersFunctionbatched_wrapper
(fn)
src/flux2/sampling.py:106
↓ 2 callersFunctioncap_pixels
(img: Image.Image | list[Image.Image], k)
src/flux2/sampling.py:178
↓ 2 callersMethoddecode
(self, z: Tensor)
src/flux2/autoencoder.py:327
↓ 2 callersMethodformat_input
Format a batch of text prompts into the conversation format expected by apply_chat_template. Optionally, add images to the input.
src/flux2/text_encoder.py:75
↓ 2 callersFunctionload_text_encoder
(model_name: str, device: str | torch.device = "cuda")
src/flux2/util.py:129
↓ 2 callersFunctionparse_key_values
Parse shell-like 'key=value' pairs. Values can be quoted. Example: prompt="a dog" width=768 input_images="in1.png,in2.jpg"
scripts/cli.py:127
↓ 2 callersMethodtest_image
(self, image)
src/flux2/text_encoder.py:424
↓ 2 callersFunctionvalidate_model_params
Validate that config parameters match model requirements. Returns True if valid.
scripts/cli.py:212
↓ 1 callersMethod__init__
( self, model_spec: str, device: str | torch.device = "cuda", )
src/flux2/text_encoder.py:367
↓ 1 callersFunction_blend_double_mods
Blend double block modulations (mod1, mod2) for [ref, img] layout.
src/flux2/model.py:346
↓ 1 callersFunction_blend_single_mods
Blend single block modulations for [txt, ref, img] layout.
src/flux2/model.py:356
↓ 1 callersMethod_format_messages
( self, prompt: str, system_message: str, images: list[Image.Image] | None = N
src/flux2/openrouter_api_client.py:39
↓ 1 callersMethod_validate_and_process_images
( self, img: list[list[Image.Image]] | list[Image.Image] )
src/flux2/text_encoder.py:56
↓ 1 callersMethodattention
(self, h_: Tensor)
src/flux2/autoencoder.py:36
↓ 1 callersFunctioncap_min_pixels
(img: Image.Image | list[Image.Image], max_ar=8, min_sidelength=64)
src/flux2/sampling.py:195
↓ 1 callersFunctioncenter_crop_to_multiple_of_x
( img: Image.Image | list[Image.Image], x: int )
src/flux2/sampling.py:159
↓ 1 callersFunctioncoerce_value
Convert a raw string to the correct field type.
scripts/cli.py:67
↓ 1 callersFunctioncompress_time
(t_ids: Tensor)
src/flux2/sampling.py:12
↓ 1 callersFunctioncompute_empirical_mu
(image_seq_len: int, num_steps: int)
src/flux2/sampling.py:251
↓ 1 callersFunctionconcatenate_images
Concatenate a list of PIL images horizontally with center alignment and white background.
src/flux2/sampling.py:413
↓ 1 callersFunctiondefault_images_prep
( x: Image.Image | list[Image.Image], )
src/flux2/sampling.py:217
↓ 1 callersFunctiondefault_prep
( img: Image.Image | list[Image.Image], limit_pixels: int | None, ensure_multiple: int = 16 )
src/flux2/sampling.py:226
↓ 1 callersFunctiondenoise_cfg
( model: Flux2, img: Tensor, img_ids: Tensor, txt: Tensor, # Already cat([txt_empty, txt_prom
src/flux2/sampling.py:364
↓ 1 callersFunctionencode_image_refs
(ae, img_ctx: list[Image.Image])
src/flux2/sampling.py:52
↓ 1 callersMethodforward_kv_cached
Subsequent denoising steps using cached KV for reference tokens. Input x has layout [img] only (no ref tokens).
src/flux2/model.py:267
↓ 1 callersFunctiongeneralized_time_snr_shift
(t: Tensor, mu: float, sigma: float)
src/flux2/sampling.py:240
↓ 1 callersFunctionget_schedule
(num_steps: int, image_seq_len: int)
src/flux2/sampling.py:244
↓ 1 callersFunctionimage_to_base64
Convert PIL Image to base64 string.
src/flux2/util.py:169
↓ 1 callersMethodinv_normalize
(self, z)
src/flux2/autoencoder.py:308
↓ 1 callersFunctionlisted_wrapper
(fn)
src/flux2/sampling.py:122
↓ 1 callersFunctionload_ae
(model_name: str, device: str | torch.device = "cuda")
src/flux2/util.py:134
↓ 1 callersFunctionload_flow_model
(model_name: str, debug_mode: bool = False, device: str | torch.device = "cuda")
src/flux2/util.py:91
↓ 1 callersMethodnormalize
(self, z)
src/flux2/autoencoder.py:304
↓ 1 callersFunctionprint_help
()
scripts/cli.py:168
↓ 1 callersFunctionrope
(pos: Tensor, dim: int, theta: int)
src/flux2/model.py:818
↓ 1 callersFunctionscatter_ids
using position ids to scatter tokens into place
src/flux2/sampling.py:24
↓ 1 callersMethodtest_txt
(self, txt: str)
src/flux2/text_encoder.py:421
↓ 1 callersFunctionto_rgb
(img: Image.Image | list[Image.Image])
src/flux2/sampling.py:206
↓ 1 callersMethodupsample_prompt
Upsample prompts using OpenRouter API. Args: txt: List of input prompts to upsample img: Optional list of im
src/flux2/openrouter_api_client.py:69
↓ 1 callersMethodupsample_prompt
(self, txt: list[str], img=None, **kwargs)
src/flux2/text_encoder.py:427
Method__call__
Adds a predefined watermark to the input image Args: image: ([N,] B, RGB, H, W) in range [-1, 1] Returns:
src/flux2/watermark.py:13
Method__init__
Initialize the OpenRouter API client. Args: model: Model name to use for upsampling. Defaults to "mistralai/pixtral-larg
src/flux2/openrouter_api_client.py:18
Method__init__
(self, watermark)
src/flux2/watermark.py:7
Method__init__
(self, in_channels: int)
src/flux2/autoencoder.py:25
Method__init__
(self, in_channels: int, out_channels: int)
src/flux2/autoencoder.py:55
Method__init__
(self, in_channels: int)
src/flux2/autoencoder.py:85
Method__init__
(self, in_channels: int)
src/flux2/autoencoder.py:98
Method__init__
( self, ch: int, out_ch: int, ch_mult: list[int], num_res_blocks: int,
src/flux2/autoencoder.py:185
Method__init__
(self, params: AutoEncoderParams)
src/flux2/autoencoder.py:272
Method__init__
( self, dim: int, num_heads: int = 8, )
src/flux2/model.py:376
Method__init__
(self)
src/flux2/model.py:391
Method__init__
(self, dim: int, double: bool, disable_bias: bool = False)
src/flux2/model.py:401
Method__init__
( self, hidden_size: int, out_channels: int, )
src/flux2/model.py:416
Method__init__
( self, hidden_size: int, num_heads: int, mlp_ratio: float = 4.0, )
src/flux2/model.py:438
Method__init__
( self, hidden_size: int, num_heads: int, mlp_ratio: float, )
src/flux2/model.py:525
Method__init__
(self, in_dim: int, hidden_dim: int, disable_bias: bool = False)
src/flux2/model.py:684
Method__init__
(self, dim: int, theta: int, axes_dim: list[int])
src/flux2/model.py:695
Method__init__
(self, dim: int)
src/flux2/model.py:735
Method__init__
(self, dim: int)
src/flux2/model.py:747
Method__init__
( self, model_spec: str = "mistralai/Mistral-Small-3.2-24B-Instruct-2506", model_spec_
src/flux2/text_encoder.py:34
Functionbatched_prc
(x: Tensor, t_coord: Tensor | None = None)
src/flux2/sampling.py:107
Functiondenoise
( model: Flux2, # model input img: Tensor, img_ids: Tensor, txt: Tensor, txt_ids: Tens
src/flux2/sampling.py:269
Functiondenoise_cached
Denoise with KV caching for reference image tokens. Step 0: model.forward_kv_extract() — full pass with ref tokens, extracts KV cache. Steps
src/flux2/sampling.py:310
Methodforward
(self, x: Tensor)
src/flux2/autoencoder.py:50
Methodforward
(self, x)
src/flux2/autoencoder.py:68
Methodforward
(self, x: Tensor)
src/flux2/autoencoder.py:90
Methodforward
(self, x: Tensor)
src/flux2/autoencoder.py:102
Methodforward
(self, x: Tensor)
src/flux2/autoencoder.py:159
Methodforward
(self, z: Tensor)
src/flux2/autoencoder.py:239
Methodforward
( self, x: Tensor, x_ids: Tensor, timesteps: Tensor, ctx: Tensor,
src/flux2/model.py:115
Methodforward
(self, x: Tensor)
src/flux2/model.py:395
Methodforward
(self, vec: torch.Tensor)
src/flux2/model.py:407
Methodforward
(self, x: torch.Tensor, vec: torch.Tensor)
src/flux2/model.py:426
Methodforward
(self, x: Tensor)
src/flux2/model.py:690
Methodforward
(self, ids: Tensor)
src/flux2/model.py:701
Methodforward
(self, x: Tensor)
src/flux2/model.py:739
Methodforward
(self, q: Tensor, k: Tensor, v: Tensor)
src/flux2/model.py:752
Methodforward
(self, txt: list[str])
src/flux2/text_encoder.py:218
Methodforward
(self, txt: list[str])
src/flux2/text_encoder.py:384
Methodforward_kv_cached
Forward using cached ref KV. Input x has layout [txt, img] (no ref).
src/flux2/model.py:508
Methodforward_kv_cached
Forward using cached ref KV. img has layout [img] only (no ref).
src/flux2/model.py:663
Methodforward_kv_extract
Forward with causal attention. Extracts and returns ref KV cache.
src/flux2/model.py:486
Methodforward_kv_extract
Forward with causal attention. img has layout [ref, img]. Extracts ref KV cache.
src/flux2/model.py:637
next →1–100 of 110, ranked by callers