Introduction to the Flux Project
Flux is a cutting-edge project by Black Forest Labs, focused on innovative models that transform text to image and image to image using their proprietary latent rectified flow transformers. Their technology allows for creative and efficient visual content generation. The project's API documentation is available at docs.bfl.ml.
Collaboration and Sampling
Flux has partnered with several platforms, including Replicate, FAL, Mystic, and Together, enabling users to sample their models through these services. Each partner offers various links where users can explore and utilize Flux's models. For instance:
- Replicate provides access through collections such as Flux Pro and Flux Dev among others.
- FAL hosts models like Flux Pro and Flux Schnell.
- Mystic offers flux1 variants.
- Together provides a playground for interactive use of Flux models, with some free access promotions valid until the end of 2024.
Models Offered
Flux provides a range of models for different user needs:
- FLUX1.1 [pro] and FLUX.1 [pro] are accessible only through their API.
- FLUX.1 [dev] is a guidance-distilled variant.
- FLUX.1 [schnell] incorporates guidance and step-distillation for fast performance.
These models have different availability and requirements, with some like FLUX.1 [schnell] being available on HuggingFace under an Apache-2.0 license.
Local Installation
To run Flux models locally, users can clone the repository and set up a Python virtual environment. All dependencies can be installed using Pip, facilitating easy setup for model use.
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]"
Usage and Integration
Users can download and utilize the models via a streamlined process. Once the model weights are downloaded, users have several options for generating images. Commands and scripts allow for interactive sampling or single sample generation.
For interactive experiences, Flux supports both Streamlit and Gradio-based demos. These platforms enable users to interact with the models in a user-friendly manner. For instance:
-
Streamlit Demo allows for both text-to-image and image-to-image transformations.
streamlit run demo_st.py
-
Gradio Demo offers a more customizable setup with public link sharing capabilities.
python demo_gr.py --name flux-dev --share
Moreover, Flux integrates with the Diffusers library, broadening its applicability and allowing for seamless pipeline use with models like FLUX.1 [schnell] and FLUX.1 [dev].
API Usage
The Flux API provides robust access to these innovative models. Interested users need to register on api.bfl.ml to obtain API keys and can manage their image generation requests through a straightforward Python interface or command line commands.
Example of Python API use:
from flux.api import ImageRequest
# Create API request and wait for completion
request = ImageRequest("A beautiful beach", name="flux.1.1-pro")
# Access the generated image
image = request.image
Conclusion
Flux by Black Forest Labs offers a state-of-the-art solution for generating creative visual content through text and images. Their innovative models and broad integration possibilities make Flux a fantastic resource for developers and creative professionals looking for advanced image generation tools.