Skip to main content

How to deploy FLUX.1

In this guide, we will create a simple FLUX image generation workflow using Ikomia API and deploy it to the cloud with Ikomia SCALE to integrate it into a Node.js application.

FLUX generated image

💫 This tutorial is also available as a Jupyter notebook.


1. Installation

First, ensure that you have installed the Ikomia Python API and CLI:

pip install ikomia ikomia-cli

2. Create a workflow with Ikomia API

To get started, let's create a workflow using infer_flux_1 algorithm from Ikomia HUB:

from ikomia.dataprocess.workflow import Workflow

workflow = Workflow("FLUX Image Generation")

flux = workflow.add_task(name="infer_flux_1")
flux.set_parameters({
"model_name": "flux1-schnell",
})

# Save workflow as a JSON file
workflow.save("flux_workflow.json")

Running your workflow locally

Ikomia API is open-source and also highly suitable for self-hosted solutions if you prefer to run workflows locally.

Here's how you can modify the previous script to execute the workflow locally:

from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

workflow = Workflow("FLUX Image Generation")
flux = workflow.add_task(name="infer_flux_1")

# Configure the algorithm
flux.set_parameters({
"model_name": "flux1-schnell",
"prompt": "An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.",
})

# Run the workflow
workflow.run()

# Display the output image
display(flux.get_output(0).get_image())
warning

Please note that FLUX is a large model that requires at least 12GB of VRAM.

To create more advanced workflows, check out the Ikomia API documentation.


3. Deploy your workflow to Ikomia SCALE

If you haven't already, create an Ikomia account.

Create an API token

To authorize the CLI and your code to access your Ikomia SCALE account, create an API token and set it as an environment variable:

export IKOMIA_TOKEN=PASTE_YOUR_TOKEN_HERE

Push your workflow

Create a project and push your workflow to Ikomia SCALE:

ikcli project add YOUR_USERNAME FluxImageGeneration
ikcli project push FluxImageGeneration flux_workflow.json

You can now view and manage your project and workflow on the Ikomia SCALE dashboard.

Deploy

warning

To deploy large algorithms like FLUX, you'll need to upgrade your plan to a paid subscription to access GPU deployments.

On the workflow page, select a deployment option and click on the Add deployment button.

Deploying our FLUX image generation workflow on a cloud GPU instance

Once your deployment is ready, you can test it via our online interface.


4. Integrate your deployment into a Node.js application

Note

We also provide a REST API for integration with any language/platform.

Install our JavaScript client library:

npm install @ikomia/ikclient

Now, you can call your deployment from your Node.js application:

import fs from "fs";
import {Client} from "@ikomia/ikclient";

// Initialize the client with your deployment URL and token
const client = new Client({
url: "https://your.deployment.url",
token: "PASTE_YOUR_TOKEN_HERE",
});

// Generate an image
const results = await client.run({
parameters: {
prompt: "An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.",
},
});

// Save the image
const image = results.getOutput(0);
await fs.promises.writeFile("output.png", image.buffer);

For more advanced usage of the Ikomia SCALE JavaScript client library, check out the client documentation.