Skip to main content

Flux AI Image Generator Tutorial: Setup Guide for Cloud GPU (2024)

· 4 min read
Vishnu Subramanian
Founder @JarvisLabs.ai
Step-by-step guide to install and run Flux.1 AI image generator on cloud GPU. Learn how to generate high-quality AI images using Flux's open-source model with detailed setup instructions and examples.

Flux on Jarvislabs Flux is an emerging open-source AI image generator that has garnered attention for its capability to produce highly realistic images, particularly of human figures. Developed by Black Forest Labs, the team behind Flux includes engineers from Stability AI, known for their work on the SDXL text-to-image generative model. Flux stands out due to its ability to generate detailed images quickly and accurately, including complex features like human hands and text descriptions in the image, which have historically been challenges for AI models

Black Forest Labs has released a suite of models under the name FLUX, with different capabilities.

  1. FLUX.1 [pro]: This is the most powerful variant, designed for high-quality image generation with superior prompt compliance and visual detail. It is accessible via API only. This model is tailored for commercial use and is noted for outperforming existing models such as MidJourney and DALL-E 3 in various benchmarks.

  2. FLUX.1 [dev]: Aimed at developers and researchers, this model is available for non-commercial purposes. It features a 12 billion parameter rectified flow transformer, enabling it to generate images from text descriptions efficiently. This version is accessible through platforms like Hugging Face and is designed to foster innovation and collaboration in the AI community. The weights are available in huggingface. You need to accept their terms and conditions before using it. This model can be used only for non commercial purpose.

  3. FLUX.1 [schnell]: This model is optimized for speed, making it suitable for personal and local use. It is designed to generate images quickly while maintaining reasonable quality, catering to users who require rapid output. It is a distilled version of pro model, can genereate great quality images in 4 steps. This model is available under apache license, and we will be using it.

Flux on Jarvislabs

Run Flux on JarvisLabs

With Jarvislabs, you get access to powerful Nvidia GPUs without upfront investments and key softwares pre configured. We will use a PyTorch instance which comes with

  • JupyterLab
  • VSCode
  • SSH access
  • An API endpoint

We will use Jupyterlab to set up a gradio application that allows us to genereate some cool images.

If you are new to Jarvislabs

Follow the below steps to create your first instance.

  • Create a new account here
  • Setup billing here and add funds to your Jarvislabs.ai wallet.
  • Choose RTX 6000Ada from here or any GPU that has 40+ GB of GPU memory, choose a storage of 50+ GB and click the launch instance button.

Setting up Flux

Once you have created an instance, click on the Jupyterlab icon from your instances page. Open a terminal and type the below commands.

Need help on how to access a terminal from JupyterLab, check this.

git clone https://github.com/black-forest-labs/flux
cd flux
python3.10 -m venv .venv
source .venv/bin/activate
pip install -e '.[all]'

Running Flux

There are couple of ways you can run Flux, the easiest I could find was running the gradio app that comes with the repo.

From the command line

Once we have installed all the required libraries, we can run the below command to generate images.

python -m flux --name flux-schnell \
--height 512 --width 512 \
--prompt "a figurine of a cute disney character holding up a sign saying 'Jarvislabs is the best' , stylized, 3d model"

When you run it, it has to download model weights of 23GB which could take a while. Not just downloading, loading these models also take a lot of time. So please be patient.

Run a gradio app

Start the gradio app from the terminal, gradio provides a GUI to play with the model.

python demo_gr.py --name flux-schnell --device cuda

Gradio APP for flux

Run a streamlit app

To run a streamlit app, run the below command from terminal.

streamlit run demo_st.py

Streamlit APP for flux

Conclusion

Flux by Black Forest Labs represents a significant advancement in AI image generation, offering powerful tools for creators across various industries. By leveraging JarvisLabs, you can easily access the computational power needed to run Flux without investing in expensive hardware.

Whether you're an artist, developer, or professional looking to integrate AI-generated images into your work, Flux on JarvisLabs provides an accessible and potent solution. The combination of Flux's high-quality output and JarvisLabs' user-friendly environment makes it easier than ever to explore the possibilities of AI-driven creativity.

Turn your imaginative prompts into stunning visual realities today!