Skip to main content

Workflows with Ikomia API

You can create a workflow using our Python API.

Installation

Recommended

As Ikomia API automatically installs algorithm dependencies, we strongly recommend using a virtual environment to avoid conflicts with your system packages.

python -m venv .venv
.venv\Scripts\Activate.bat

Just install the Ikomia package and the CLI using pip:

pip install ikomia ikomia-cli

Make your own workflow

Here's a minimal code example demonstrating how to create a workflow that blurs faces in an image using the Ikomia API:

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

wf = Workflow()

face = wf.add_task(ik.infer_face_detection_kornia(), auto_connect=True)
blur = wf.add_task(ik.ocv_blur(kSizeWidth="61", kSizeHeight="61"), auto_connect=True)

wf.run_on(url="https://raw.githubusercontent.com/Ikomia-dev/notebooks/main/examples/img/img_people.jpg")

display(blur.get_output(0).get_image())

For a step-by-step guide and more detailed examples, please refer to our Python API documentation.

Push a workflow to SCALE

To push your workflow, first export it to a JSON file using the Workflow.save method:

wf.save("path/to/your/workflow.json")

Once you have your workflow file, log in to your Ikomia account:

ikcli login
# Export generated access token to your environment variables:
export IKOMIA_TOKEN=<your_access_token>
note

If you have not defined a password on your account, you can generate an access token from your settings and export it to your environment variables directly.

Then, use the Ikomia CLI push command:

ikcli project push <ProjectName> <path/to/your/workflow.json>

Under the hood, the CLI will package your JSON workflow file alongside the algorithms it depends on and upload them to SCALE.

You will then be able to see your workflow in the project you specified from the SCALE dashboard. From there, you'll be able to deploy it on the infrastructure of your choice.