Skip to content

Commit

Permalink
✨ Generate inference types for existing tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
SBrandeis committed Jan 19, 2024
1 parent bbf72ec commit 16a9beb
Show file tree
Hide file tree
Showing 22 changed files with 1,134 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/audio-classification/inference.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T14:59:10.562Z
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
Expand Down
31 changes: 31 additions & 0 deletions packages/tasks/src/tasks/automatic-speech-recognition/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Automatic Speech Recognition inference
*/
export interface AutomaticSpeechRecognitionInput {
/**
* The input audio data
*/
inputs: any;
/**
* Additional inference parameters
*/
parameters?: { [key: string]: any };
[property: string]: any;
}

/**
* Outputs of inference for the Automatic Speech Recognition task
*/
export interface AutomaticSpeechRecognitionOutput {
/**
* The recognized text.
*/
text: string;
[property: string]: any;
}
33 changes: 33 additions & 0 deletions packages/tasks/src/tasks/depth-estimation/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Depth Estimation inference
*/
export interface DepthEstimationInput {
/**
* The input image data
*/
inputs: any;
/**
* Additional inference parameters
*/
parameters?: DepthEstimationParameters;
[property: string]: any;
}

/**
* Additional inference parameters
*
* Additional inference parameters for Depth Estimation
*/
export interface DepthEstimationParameters {
/**
* When specified, limits the output to the top K most probable classes.
*/
topK?: number;
[property: string]: any;
}
101 changes: 101 additions & 0 deletions packages/tasks/src/tasks/document-question-answering/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Document Question Answering inference
*/
export interface DocumentQuestionAnsweringInput {
/**
* The
*/
inputs: DocumentAndQuestion[] | DocumentAndQuestion;
/**
* Additional inference parameters
*/
parameters?: DocumentQuestionAnsweringParameters;
[property: string]: any;
}

export interface DocumentAndQuestion {
/**
* The image on which the question is asked
*/
image?: any;
/**
* A question to ask of the document
*/
question?: string;
[property: string]: any;
}

/**
* Additional inference parameters
*
* Additional inference parameters for Document Question Answering
*/
export interface DocumentQuestionAnsweringParameters {
/**
* If the words in the document are too long to fit with the question for the model, it will
* be split in several chunks with some overlap. This argument controls the size of that
* overlap.
*/
docStride?: number;
/**
* Whether to accept impossible as an answer
*/
handleImpossibleAnswer?: boolean;
/**
* Language to use while running OCR. Defaults to english.
*/
lang?: string;
/**
* The maximum length of predicted answers (e.g., only answers with a shorter length are
* considered).
*/
maxAnswerLen?: number;
/**
* The maximum length of the question after tokenization. It will be truncated if needed.
*/
maxQuestionLen?: number;
/**
* The maximum length of the total sentence (context + question) in tokens of each chunk
* passed to the model. The context will be split in several chunks (using doc_stride as
* overlap) if needed.
*/
maxSeqLen?: number;
/**
* The number of answers to return (will be chosen by order of likelihood). Can return less
* than top_k answers if there are not enough options available within the context.
*/
topK?: number;
/**
* A list of words and bounding boxes (normalized 0->1000). If provided, the inference will
* skip the OCR step and use the provided bounding boxes instead.
*/
wordBoxes?: Array<number[] | string>;
[property: string]: any;
}

/**
* Outputs of inference for the Document Question Answering task
*/
export interface DocumentQuestionAnsweringOutput {
/**
* The answer to the question.
*/
answer: string;
end: number;
/**
* The probability associated to the answer.
*/
score: number;
start: number;
/**
* The index of each word/box pair that is in the answer
*/
words: number[];
[property: string]: any;
}
20 changes: 20 additions & 0 deletions packages/tasks/src/tasks/feature-extraction/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Feature Extraction inference
*/
export interface FeatureExtractionInput {
/**
* One or several texts to get the features of
*/
inputs: string[] | string;
/**
* Additional inference parameters
*/
parameters?: { [key: string]: any };
[property: string]: any;
}
63 changes: 63 additions & 0 deletions packages/tasks/src/tasks/fill-mask/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Fill Mask inference
*/
export interface FillMaskInput {
/**
* One or several texts with masked tokens
*/
inputs: string[] | string;
/**
* Additional inference parameters
*/
parameters?: FillMaskParameters;
[property: string]: any;
}

/**
* Additional inference parameters
*
* Additional inference parameters for Fill Mask
*/
export interface FillMaskParameters {
/**
* When passed, the model will limit the scores to the passed targets instead of looking up
* in the whole vocabulary. If the provided targets are not in the model vocab, they will be
* tokenized and the first resulting token will be used (with a warning, and that might be
* slower).
*/
targets?: string[] | string;
/**
* When passed, overrides the number of predictions to return.
*/
topK?: number;
[property: string]: any;
}

/**
* Outputs of inference for the Fill Mask task
*/
export interface FillMaskOutput {
/**
* The corresponding probability
*/
score: number;
/**
* The corresponding input with the mask token prediction.
*/
sequence: string;
/**
* The predicted token id (to replace the masked one).
*/
token: number;
/**
* The predicted token (to replace the masked one).
*/
tokenStr: string;
[property: string]: any;
}
48 changes: 48 additions & 0 deletions packages/tasks/src/tasks/image-classification/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Image Classification inference
*/
export interface ImageClassificationInput {
/**
* On or several image files to classify
*/
inputs: any;
/**
* Additional inference parameters
*/
parameters?: ImageClassificationParameters;
[property: string]: any;
}

/**
* Additional inference parameters
*
* Additional inference parameters for Image Classification
*/
export interface ImageClassificationParameters {
/**
* When specified, limits the output to the top K most probable classes.
*/
topK?: number;
[property: string]: any;
}

/**
* Outputs of inference for the Image Classification task
*/
export interface ImageClassificationOutput {
/**
* The predicted class label (model specific).
*/
label: string;
/**
* The corresponding probability.
*/
score: number;
[property: string]: any;
}
64 changes: 64 additions & 0 deletions packages/tasks/src/tasks/image-segmentation/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Image Segmentation inference
*/
export interface ImageSegmentationInput {
/**
* One or several image files to perform segmentation on
*/
inputs: any;
/**
* Additional inference parameters
*/
parameters?: ImageSegmentationParameters;
[property: string]: any;
}

/**
* Additional inference parameters
*
* Additional inference parameters for Image Segmentation
*/
export interface ImageSegmentationParameters {
/**
* Threshold to use when turning the predicted masks into binary values.
*/
maskThreshold?: number;
/**
* Mask overlap threshold to eliminate small, disconnected segments.
*/
overlapMaskAreaThreshold?: number;
/**
* Segmentation task to be performed, depending on model capabilities.
*/
subtask?: Subtask;
/**
* Probability threshold to filter out predicted masks.
*/
threshold?: number;
[property: string]: any;
}

export type Subtask = "instance" | "panoptic" | "semantic";

/**
* Outputs of inference for the Image Segmentation task
*
* A predicted mask / segment
*/
export interface ImageSegmentationOutput {
/**
* The label of the predicted segment
*/
label: string;
/**
* The corresponding mask as a black-and-white image
*/
mask: any;
[property: string]: any;
}
20 changes: 20 additions & 0 deletions packages/tasks/src/tasks/image-to-image/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Inference code generated from the JSON schema spec in ./spec
*
* Generated on 2024-01-19T16:16:01.752Z
*/

/**
* Inputs for Image To Image inference
*/
export interface ImageToImageInput {
/**
* One or more images to generate images from
*/
inputs: any;
/**
* Additional inference parameters
*/
parameters?: any;
[property: string]: any;
}
Loading

0 comments on commit 16a9beb

Please sign in to comment.