### Run Interactive Text-to-Image Sampling Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Start an interactive sampling session for text-to-image generation. Use 'flux-dev' or 'flux-schnell' as the name. ```bash python -m flux t2i --name --loop ``` -------------------------------- ### Run Gradio Text-to-Image Demo Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Start the Gradio-based demo for an interactive text-to-image experience. Specify the model name and device. Options include offloading to CPU and creating public links. ```bash python demo_gr.py --name flux-schnell --device cuda ``` ```bash python demo_gr.py --name flux-dev --share ``` -------------------------------- ### Install Diffusers Library Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Install the diffusers library from its GitHub repository to integrate with Flux models. ```shell pip install git+https://github.com/huggingface/diffusers.git ``` -------------------------------- ### Local Installation of FLUX Source: https://github.com/black-forest-labs/flux/blob/main/README.md Installs the FLUX repository and its dependencies for local use. Ensure Python 3.10 and a virtual environment are set up. ```bash cd $HOME && git clone https://github.com/black-forest-labs/flux cd $HOME/flux python3.10 -m venv .venv source .venv/bin/activate pip install -e ".[all]" ``` -------------------------------- ### Local Installation with TensorRT Support Source: https://github.com/black-forest-labs/flux/blob/main/README.md Installs FLUX with TensorRT support, requiring NVIDIA's PyTorch image and enroot. Follow the steps to import, create, and start an enroot container. ```bash cd $HOME && git clone https://github.com/black-forest-labs/flux enroot import 'docker://$oauthtoken@nvcr.io#nvidia/pytorch:25.01-py3' enroot create -n pti2501 nvidia+pytorch+25.01-py3.sqsh enroot start --rw -m ${PWD}/flux:/workspace/flux -r pti2501 cd flux pip install -e ".[tensorrt]" --extra-index-url https://pypi.nvidia.com ``` -------------------------------- ### Run Interactive Fill Mode Source: https://github.com/black-forest-labs/flux/blob/main/docs/fill.md Command to start the interactive sampling mode for FLUX.1 Fill. This mode allows for continuous generation and editing. ```bash python -m flux fill --loop ``` -------------------------------- ### TensorRT Engine Inference with Flux Kontext Source: https://github.com/black-forest-labs/flux/blob/main/docs/image-editing.md Perform inference using a TensorRT engine. Replace `` with 'bf16', 'fp8', or 'fp4_sdvd32'. Ensure TensorRT support is installed. ```bash python -m flux kontext --loop --trt --trt_transformer_precision ``` -------------------------------- ### Run TRT Engine Inference with FLUX Control Source: https://github.com/black-forest-labs/flux/blob/main/docs/structural-conditioning.md Perform inference using the TensorRT (TRT) engine with FLUX control. Supports BF16, FP8, and FP4 precisions. Requires TensorRT support to be installed. ```bash python flux control --name= --loop --img_cond_path="assets/robot.webp" --trt --static_shape=False --trt_transformer_precision ``` -------------------------------- ### Run Streamlit Text-to-Image Demo Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Launch the Streamlit-based demo for interactive text-to-image and image-to-image generation. ```bash streamlit run demo_st.py ``` -------------------------------- ### Interactive Sampling with Flux Kontext Source: https://github.com/black-forest-labs/flux/blob/main/docs/image-editing.md Run this command for interactive sampling. The weights will be downloaded automatically if not found. ```bash python -m flux kontext --loop ``` -------------------------------- ### Run FLUX.1 Kontext with Usage Tracking Source: https://github.com/black-forest-labs/flux/blob/main/README.md Execute FLUX.1 Kontext with the --track_usage and --loop flags for continuous generation with tracking. This command is suitable for development and testing. ```bash python -m flux kontext --track_usage --loop ``` -------------------------------- ### Run Streamlit Demo for Fill Source: https://github.com/black-forest-labs/flux/blob/main/docs/fill.md Command to launch the interactive Streamlit demo for FLUX.1 Fill. This provides a user-friendly interface for experimenting with the model. ```bash streamlit run demo_st_fill.py ``` -------------------------------- ### Generate a Single Text-to-Image Sample Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Generate a single image based on a prompt, specifying dimensions and the prompt text. Use 'flux-dev' or 'flux-schnell' as the name. ```bash python -m flux t2i --name \ --height --width \ --prompt "" ``` -------------------------------- ### Single Generation with FLUX.1 Kontext and Usage Tracking Source: https://github.com/black-forest-labs/flux/blob/main/README.md Perform a single image generation or editing task using FLUX.1 Kontext with usage tracking. Provide your prompt using the --prompt flag. ```bash python -m flux kontext --track_usage --prompt "replace the logo with the text 'Black Forest Labs'" ``` -------------------------------- ### Run Interactive Sampling for FLUX Control Source: https://github.com/black-forest-labs/flux/blob/main/docs/structural-conditioning.md Execute interactive sampling for FLUX control models. The 'name' parameter should be one of the available control variants. ```bash python -m flux control --name --loop ``` -------------------------------- ### Generate Single Sample with Flux Kontext Source: https://github.com/black-forest-labs/flux/blob/main/docs/image-editing.md Generate a single image sample using specified parameters. Optional flags include num_steps, aspect_ratio, guidance, and seed. ```bash python -m flux kontext \ --img_cond_path \ --prompt \ --num_steps 30 --aspect_ratio "16:9" --guidance 2.5 --seed 1 ``` -------------------------------- ### Run Interactive Sampling for Image Variation Source: https://github.com/black-forest-labs/flux/blob/main/docs/image-variation.md Execute this command for interactive image variation generation. Specify the base model name using the --name argument. ```bash python -m flux redux --name --loop ``` -------------------------------- ### Generate Single Sample with Fill Source: https://github.com/black-forest-labs/flux/blob/main/docs/fill.md Command to generate a single sample using FLUX.1 Fill with specified conditioning and mask images. Ensure the mask image is black and white and matches the conditioning image dimensions. ```bash python -m flux fill \ --img_cond_path \ --img_mask_path ``` -------------------------------- ### Set API Key for Usage Tracking Source: https://github.com/black-forest-labs/flux/blob/main/README.md Set your BFL_API_KEY environment variable before running FLUX.1 Kontext with tracking enabled. This is required for commercial licensing and usage reporting. ```bash export BFL_API_KEY="your_api_key_here" ``` -------------------------------- ### Set FLUX Model and Autoencoder Paths Source: https://github.com/black-forest-labs/flux/blob/main/docs/fill.md Environment variables to specify the paths for the FLUX model and autoencoder weights. These are used when downloading weights manually. ```bash export FLUX_MODEL= export FLUX_AE= ``` -------------------------------- ### Use Flux Pipeline with Diffusers Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Load and use the FluxPipeline from the diffusers library for text-to-image generation. Supports specifying model ID, data type, prompt, inference steps, and a random seed. ```python import torch from diffusers import FluxPipeline model_id = "black-forest-labs/FLUX.1-schnell" #you can also use `black-forest-labs/FLUX.1-dev` pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16) pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power prompt = "A cat holding a sign that says hello world" seed = 42 image = pipe( prompt, output_type="pil", num_inference_steps=4, #use a larger number if you are using [dev] generator=torch.Generator("cpu").manual_seed(seed) ).images[0] image.save("flux-schnell.png") ``` -------------------------------- ### Text-to-Image Inference with TensorRT Source: https://github.com/black-forest-labs/flux/blob/main/docs/text-to-image.md Run text-to-image inference using TensorRT engines with specified precision (bf16, fp8, or fp4). For ONNX exports, height and width must be between 768 and 1344. ```bash python -m flux t2i --name= --loop --trt --trt_transformer_precision ``` -------------------------------- ### Set Environment Variables for FLUX.1 Redux Source: https://github.com/black-forest-labs/flux/blob/main/docs/image-variation.md Set these environment variables to manually specify the paths for the FLUX.1 model, Redux adapter, and autoencoder if not downloading automatically. ```bash export FLUX_MODEL= export FLUX_REDUX= export FLUX_AE= ``` -------------------------------- ### Set Environment Variables for FLUX Models Source: https://github.com/black-forest-labs/flux/blob/main/docs/structural-conditioning.md Set environment variables to specify the paths for the FLUX model, autoencoder, and optionally LoRA adapters. This is useful for manual model management. ```bash export FLUX_MODEL= export FLUX_AE= # optional (see below) export FLUX_LORA= ``` -------------------------------- ### FLUX Project Citation Source: https://github.com/black-forest-labs/flux/blob/main/README.md BibTeX entry for citing the FLUX project, acknowledging the open-source contribution. ```bibtex @misc{flux2024, author={Black Forest Labs}, title={FLUX}, year={2024}, howpublished={\url{https://github.com/black-forest-labs/flux}}, } ``` -------------------------------- ### FLUX.1 Kontext Citation Source: https://github.com/black-forest-labs/flux/blob/main/README.md BibTeX entry for citing the FLUX.1 Kontext paper, useful for academic research and publications. ```bibtex @misc{labs2025flux1kontextflowmatching, title={FLUX.1 Kontext: Flow Matching for In-Context Image Generation and Editing in Latent Space}, author={Black Forest Labs and Stephen Batifol and Andreas Blattmann and Frederic Boesel and Saksham Consul and Cyril Diagne and Tim Dockhorn and Jack English and Zion English and Patrick Esser and Sumith Kulal and Kyle Lacey and Yam Levi and Cheng Li and Dominik Lorenz and Jonas Müller and Dustin Podell and Robin Rombach and Harry Saini and Axel Sauer and Luke Smith}, year={2025}, eprint={2506.15742}, archivePrefix={arXiv}, primaryClass={cs.GR}, url={https://arxiv.org/abs/2506.15742}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.