
Deploy Flux 1-schnell to harness the power of open-source generative AI for creating images from text prompts. This streamlined version of the original Flux-pro model offers faster performance while retaining text embedding capabilities for enhanced image generation. Built on a transformer architecture with 12 billion parameters, Flux 1-schnell supports LoRA (Low-Rank Adaptations) to produce highly realistic images efficiently.
This article explains how to deploy the FLUX.1-schnell image generation model on a Vultr Cloud GPU server. You will use the ComfyUI web interface to create an image generation workflow and set up LoRAs to enhance the quality of the generated images.
Before you begin:
The huggingface_hub Python library includes a special function for downloading the Flux-schnell model. Follow the steps below to install the huggingface_hub library and create a new Python script to download the Flux-schnell model.
Switch to your user's home directory.
Create a new directory, such as flux to store the model files.
Switch to the new flux directory.
Use Pip to install the huggingface_hub Python library.
Create a new schnell_model_downloader.py file.
Add the following Python script to the schnell_model_downloader.py file. Replace /home/linuxuser/flux with your actual model directory.
Save and close the file.
The above Python script imports the huggingface_hub library for downloading the Flux-schnell model files. The snapshot_download function downloads the model from the black-forest-labs/FLUX.1-schnell Huggingface repository to the /home/linuxuser/flux directory.
Run the script using Python to download the Flux-schnell model files and wait at least 10 minutes for the model to download.
Output:
Move the flux1-schnell.safetensors file to the models/unet directory in your ComfyUI project.
Move the ae.safetensors file to the models/vae directory in your ComfyUI project.
The above command moves the ae.safetensors variational encoder file required by the model to enhance the visual quality of generated images.
ComfyUI requires multiple files to run models on a server. Follow the steps below to download the required Flux-schnell model files to your ComfyUI project directory.
Switch to the models/clip directory in your ComfyUI project.
Download the Flux-schnell clip_l.safetensors file.
The above command downloads the clip model used by the Flux-schnell model during the image generation process to support text inputs.
Download the Flux-schnell t5xxl_fp16.safetensors file.
The above command takes between 2 and 5 minutes to download the FP16 model file used by Flux-schnell to encode text inputs. The model uses the FP16 precision standard to balance the model's image generation quality and performance.
ComfyUI generates images using workflows in the form of interconnected nodes. Workflows connect multiple AI image generation components to produce a final image. ComfyUI loads workflows from sources such as configuration or image files. Follow the steps below to load the Flux-schnell image generation workflow and generate images using ComfyUI.
Access your ComfyUI domain using a web browser such as Chrome.
Download the following image to your workstation to load the Flux-schnell workflow in ComfyUI.
Click Load in the floating ComfyUI menu to browse and open the workflow image on your workstation.
Find the Prompt node and enter a new text prompt to generate images. For example, A photorealistic image of a golden retriever dog with soulful brown eyes, lying on a soft rug in front of a cozy fireplace, with a warm glow illuminating its fur. The dog is relaxed, with its head resting on its paws, and its tail gently curled around its body. In the background, a peaceful living room with comfy furniture and soft lighting creates a calm, serene atmosphere..
Click Queue Prompt to generate the image using the Flux-schnell model.
Wait at least 30 seconds for the image generation process to complete and verify the image in the Save Image node.
The Flux-schnell development (Flux-dev) model generates higher-quality images at a slower generation speed as compared to the main Flux-schnell model. LoRas also require the Flux-dev model in order to generate higher-quality images. Follow the steps below to generate a new Hugging Face access token and download the Flux-dev model on your server.
Visit the Flux-dev model page on Hugging Face.
Click Agree to accept the model's terms and conditions.
Visit the Tokens page in your Hugging Face account settings.
Click Create new token.
Enter your desired token name and description in the respective fields.
Check the Read access to contents of all public gated repos you can access within the User Permissions section to access the Flux-dev repository using the token.
Scroll and click Create token to apply the new token to your Hugging Face account.
Click Copy to save the token to your clipboard.
Switch to the flux directory you created earlier in your user's home directory. Replace /home/linuxuser/flux with your actual path.
Create a new dev_model_downloader.py file.
Add the following Python script to the dev_model_downloader.py file. Replace YOUR_ACCESS_TOKEN with your Hugging Face token and /home/linuxuser/flux with your actual path.
Save and close the file.
The above Python script runs the login(...) function from the huggingface_hub library to download the Flux-dev model using the snapshot_download(...) function and your Hugging Face token.
Run the dev_model_downloader.py script using Python.
Wait at least 10 minutes for the model to finish downloading and verify that your output is similar to the one below when successful.
Move the flux-dev model files to the models/unet directory in your ComfyUI project.
Access the ComfyUI interface using your domain in a new web browser window.
Download the following image to your workstation to load a new Flux-dev workflow in ComfyUI.
The Flux-dev workflow allows you to generate images with the Flux-dev model and contains all necessary paths required by the model.
Click Load in ComfyUI to browse the image from your workstation and load the Flux-dev workflow.
Enter a new text prompt in the Prompt node. For example, enter the prompt A photorealistic image of a golden retriever dog with soulful brown eyes, lying on a soft rug in front of a cozy fireplace, with a warm glow illuminating its fur. The dog is relaxed, with its head resting on its paws, and its tail gently curled around its body. In the background, a peaceful living room with comfy furniture and soft lighting creates a calm, serene atmosphere..
Click Queue Prompt to generate the image using the Flux-dev model.
Wait at least 30 seconds for the image generation process to complete and verify the image in the Save Image node.
LoRAs are additional model files that increase the realism of generated images including faces. Follow the steps below to set up LoRAs developed by XLabs AI to increase the quality of images generated by the Flux-dev model.
Switch to the models/loras directory in your ComfyUI project.
Download the LoRAs file for the Flux-dev model.
Download the following image to your workstation to load the Flux-dev image generation workflow with LoRAs in ComfyUI.
Click Load in ComfyUI to browse the image and open the LoRAs workflow.
Enter a new text prompt in the Prompt that contains a face to test the LoRAs output. For example, enter the prompt, A photorealistic image of a young man's face with short, dark hair and smooth skin. He has a focused, thoughtful expression, with relaxed eyes and a slight, confident smile. Soft lighting from one side highlights his sharp cheekbones and well-defined jawline, bringing out the natural contours of his face. The background is simple and blurred, emphasizing his facial features and calm demeanor..
Click Queue Prompt to generate a new image using the model.
Wait at least 30 seconds for the image generation process to complete and view the image in the Save Image node.
ComfyUI may display some errors while generating images using the Flux-schnell model. Use the following solutions to fix any errors on your server.
torch.cuda.OutOfMemoryError: Upgrade your GPU server plan or clear the GPU memory to generate images using the Flux-schnell model.Numpy is not available: Verify the latest supported ComfyUI Numpy version and install it on your server. For example, Install the numpy<2 package using Pip as required by most ComfyUI versions.You have deployed the Flux-schnell model on a Vultr Cloud GPU server and generated images using ComfyUI. In addition, you deployed the Flux-dev model to increase the generated image output quality and set up LoRAs to enable the model to produce more realistic images. For more information, workflow, and model options, please visit the official Flux-schnell Hugging Face page.
0 Comments
Be the first to comment and share your perspective with the community.