Skip to main content

clarifai-nodejs / Exports / Input

Class: Input

Inputs is a class that provides access to Clarifai API endpoints related to Input information.

Hierarchy

  • Lister

    Input

Table of contents

Constructors

Methods

Constructors

constructor

new Input(params): Input

Initializes an input object.

Example

import { Input } from "clarifai-nodejs";

export const input = new Input({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
});

Parameters

NameTypeDescription
paramsObjectThe parameters for the Input object.
params.authConfig?AuthConfig-

Returns

Input

Overrides

Lister.constructor

Defined in

client/input.ts:64

Methods

patchInputs

patchInputs(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› action?string"merge"
› inputsInput[]undefined

Returns

Promise<string>

Defined in

client/input.ts:923


uploadAnnotations

uploadAnnotations(«destructured»): Promise<Annotation[]>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› batchAnnotAnnotation[]undefined
› showLog?booleantrue

Returns

Promise<Annotation[]>

Defined in

client/input.ts:959


uploadFromBytes

uploadFromBytes(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioBytes?null | Uint8Arraynull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageBytes?null | Uint8Arraynull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textBytes?null | Uint8Arraynull
› videoBytes?null | Uint8Arraynull

Returns

Promise<string>

Defined in

client/input.ts:871


uploadFromFile

uploadFromFile(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioFile?null | stringnull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageFile?null | stringnull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textFile?null | stringnull
› videoFile?null | stringnull

Returns

Promise<string>

Defined in

client/input.ts:836


uploadFromUrl

uploadFromUrl(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioUrl?null | stringnull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageUrl?null | stringnull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textUrl?null | stringnull
› videoUrl?null | stringnull

Returns

Promise<string>

Defined in

client/input.ts:801


uploadInputs

uploadInputs(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› inputsInput[]undefined
› showLog?booleantrue

Returns

Promise<string>

Defined in

client/input.ts:760


uploadText

uploadText(«destructured»): Promise<string>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› datasetId?null | stringnull
› inputIdstringundefined
› rawTextstringundefined

Returns

Promise<string>

Defined in

client/input.ts:906


getBboxProto

getBboxProto(«destructured»): Annotation

Parameters

NameType
«destructured»Object
› bboxnumber[]
› inputIdstring
› labelstring

Returns

Annotation

Defined in

client/input.ts:679


getImageInputsFromFolder

getImageInputsFromFolder(«destructured»): Input[]

Upload image inputs from folder.

Example

import { Input, Model } from "clarifai-nodejs";
import path from "path";

// Generate a new GRPC compatible Input object from buffer
const imageInputs = Input.getImageInputsFromFolder({
// Ensure the directory contains a list of images
folderPath: path.resolve(__dirname, "path/to/imageFolder"),
});

// The input can now be used as an input for a model prediction methods
const model = new Model({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
modelId: "multimodal-clip-embed",
});
const prediction = await model.predict({
inputs: imageInputs,
});
console.log(prediction);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› datasetId?null | stringnull
› folderPathstringundefined
› labels?booleanfalse

Returns

Input[]

Defined in

client/input.ts:396


getInputFromBytes

getInputFromBytes(«destructured»): Input

Creates an input proto from bytes.

Example

import { Input, Model } from "clarifai-nodejs";
import * as fs from "fs";

const imageBuffer = fs.readFileSync("path/to/image.jpg");

// Generate a new GRPC compatible Input object from buffer
const imageInput = Input.getInputFromBytes({
inputId: "demo",
imageBytes: imageBuffer,
});

// The input can now be used as an input for a model prediction methods
const model = new Model({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
modelId: "multimodal-clip-embed",
});
const prediction = await model.predict({
inputs: [imageInput],
});
console.log(prediction);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioBytes?null | Uint8Arraynull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageBytes?null | Uint8Arraynull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textBytes?null | Uint8Arraynull
› videoBytes?null | Uint8Arraynull

Returns

Input

An Input object for the specified input ID.

Defined in

client/input.ts:194


getInputFromFile

getInputFromFile(«destructured»): Input

Create input proto from files.

Example

import { Input, Model } from "clarifai-nodejs";
import path from "path";

// Generate a new GRPC compatible Input object from buffer
const imageInput = Input.getInputFromFile({
inputId: "demo",
imageFile: path.resolve(__dirname, "path/to/image.jpg"),
});

// The input can now be used as an input for a model prediction methods
const model = new Model({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
modelId: "multimodal-clip-embed",
});
const prediction = await model.predict({
inputs: [imageInput],
});
console.log(prediction);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioFile?null | stringnull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageFile?null | stringnull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textFile?null | stringnull
› videoFile?null | stringnull

Returns

Input

  • An Input object for the specified input ID.

Defined in

client/input.ts:258


getInputFromUrl

getInputFromUrl(«destructured»): Input

Upload input from URL.

Example

import { Input, Model } from "clarifai-nodejs";

// Generate a new GRPC compatible Input object from buffer
const imageInput = Input.getInputFromUrl({
inputId: "demo",
imageUrl: "https://samples.clarifai.com/dog2.jpeg",
});

// The input can now be used as an input for a model prediction methods
const model = new Model({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
modelId: "multimodal-clip-embed",
});
const prediction = await model.predict({
inputs: [imageInput],
});
console.log(prediction);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioUrl?null | stringnull
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imageUrl?null | stringnull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textUrl?null | stringnull
› videoUrl?null | stringnull

Returns

Input

  • Job ID for the upload request.

Defined in

client/input.ts:322


getInputsFromCsv

getInputsFromCsv(«destructured»): Promise<Input[]>

Create Input proto from CSV File. Supported columns are: 'inputid', 'input', 'concepts', 'metadata', 'geopoints'

Parameters

NameTypeDefault value
«destructured»Objectundefined
› csvPathstringundefined
› csvType"url" | "raw" | "file""raw"
› datasetId?null | stringnull
› inputType"image" | "text" | "video" | "audio""text"
› labelsbooleantrue

Returns

Promise<Input[]>

  • An array of Input objects for the specified input ID.

Defined in

client/input.ts:533


getMaskProto

getMaskProto(inputId, label, polygons): Annotation

Parameters

NameType
inputIdstring
labelstring
polygonsnumber[][][]

Returns

Annotation

Defined in

client/input.ts:720


getMultimodalInput

getMultimodalInput(«destructured»): Input

Create input proto for text and image from bytes or url

Parameters

NameTypeDefault value
«destructured»Objectundefined
› datasetId?null | stringnull
› imageBytes?null | Uint8Arraynull
› imageUrl?null | stringnull
› inputIdstringundefined
› rawText?null | stringnull
› textBytes?null | Uint8Arraynull

Returns

Input

  • An Input object for the specified input ID.

Defined in

client/input.ts:476


getProto

getProto(«destructured»): Input

Create input proto for image data type.

Parameters

NameTypeDefault value
«destructured»Objectundefined
› audioPb?null | { base64: string }null
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› imagePb?null | { base64: string ; url?: undefined } | { base64?: undefined ; url: string }null
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› textPb?null | { raw: string }null
› videoPb?null | { base64: string }null

Returns

Input

  • An Input object for the specified input ID.

Defined in

client/input.ts:82


getTextInput

getTextInput(«destructured»): Input

Create input proto for text data type from raw text.

Example

import { Input, Model } from "clarifai-nodejs";

// Generate a new GRPC compatible Input object from buffer
const textInput = Input.getTextInput({
inputId: "demo",
rawText: "Sample text for input generation",
});

// The input can now be used as an input for a model prediction methods
const model = new Model({
authConfig: {
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
},
modelId: "multimodal-clip-embed",
});
const prediction = await model.predict({
inputs: [textInput],
});
console.log(prediction);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› datasetId?null | stringnull
› geoInfo?null | AsObjectnull
› inputIdstringundefined
› labels?null | string[]null
› metadata?null | Record<string, JavaScriptValue>null
› rawTextstringundefined

Returns

Input

  • An Input object for the specified input ID.

Defined in

client/input.ts:439


getTextInputsFromFolder

getTextInputsFromFolder(«destructured»): Input[]

Parameters

NameTypeDefault value
«destructured»Objectundefined
› datasetIdnull | stringnull
› folderPathstringundefined
› labelsbooleanfalse

Returns

Input[]

Defined in

client/input.ts:648