-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Generate inference types for existing tasks
- Loading branch information
Showing
22 changed files
with
1,134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/tasks/src/tasks/automatic-speech-recognition/inference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
101
packages/tasks/src/tasks/document-question-answering/inference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
48
packages/tasks/src/tasks/image-classification/inference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.