Skip to main content

Custom inputs

You deployment may take non-image inputs like segmentation masks, text detection results or custom data structures.

You can pass these kinds of inputs to your deployment using the input attribute in the Client#run method.

import {Client} from "@ikomia/ikclient";
import {TaskIO} from "@ikomia/ikclient/io";

const client = new Client({
url: "https://your.scale.endpoint.url",
});

// Pass a custom input data to your deployment
const dataDict = new TaskIO({
DATA_DICT: { // Arbitrary JSON serializable data
"key1": "value1",
"key2": "value2",
"key3": "value3",
}
});

const results = await client.run({
input: dataDict
});

The input attribute accepts any of the supported standard types as well as custom data structures using the TaskIO class. You can also pass an array of inputs using the inputs attribute.

important

To pass images alongside other type of inputs, you need to pass your image as an ImageIO object to the inputs attribute:

import {ImageIO} from "@ikomia/ikclient/io";

const results = await client.run({
inputs: [
await ImageIO.create("https://raw.githubusercontent.com/Ikomia-dev/notebooks/main/examples/img/img_work.jpg"),
dataDict,
]
});

ImageIO#create is a helper method to create an ImageIO object from a supported image type.


Chaining deployments

You can use the input attribute to chain deployments together:

const results1 = await imageGenerator.run({
parameters: {
prompt: "Photorealistic photo, side profile of a lion, extreme close-up, high-resolution"
}
});

const results2 = await objectDetector.run({
input: results1.getOutput<ImageIO>(0)
});

const objects = results2.getOutput<ObjectDetectionIO>(0);
note

The inputs attribute also accepts a Results object directly, if you want to chain all the outputs of a deployment as inputs to another one.