@huggingface/tasks 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{index.mjs → index.cjs} +2695 -2497
- package/dist/index.d.ts +427 -65
- package/dist/index.js +2660 -2532
- package/package.json +13 -8
- package/src/index.ts +2 -5
- package/src/library-to-tasks.ts +1 -1
- package/src/model-data.ts +1 -1
- package/src/model-libraries-downloads.ts +20 -0
- package/src/{library-ui-elements.ts → model-libraries-snippets.ts} +50 -296
- package/src/model-libraries.ts +375 -44
- package/src/pipelines.ts +1 -1
- package/src/tasks/audio-classification/about.md +1 -1
- package/src/tasks/audio-classification/inference.ts +51 -0
- package/src/tasks/audio-classification/spec/input.json +34 -0
- package/src/tasks/audio-classification/spec/output.json +10 -0
- package/src/tasks/audio-to-audio/about.md +1 -1
- package/src/tasks/automatic-speech-recognition/about.md +4 -2
- package/src/tasks/automatic-speech-recognition/inference.ts +159 -0
- package/src/tasks/automatic-speech-recognition/spec/input.json +34 -0
- package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
- package/src/tasks/common-definitions.json +117 -0
- package/src/tasks/depth-estimation/data.ts +8 -4
- package/src/tasks/depth-estimation/inference.ts +35 -0
- package/src/tasks/depth-estimation/spec/input.json +25 -0
- package/src/tasks/depth-estimation/spec/output.json +16 -0
- package/src/tasks/document-question-answering/inference.ts +110 -0
- package/src/tasks/document-question-answering/spec/input.json +85 -0
- package/src/tasks/document-question-answering/spec/output.json +36 -0
- package/src/tasks/feature-extraction/inference.ts +22 -0
- package/src/tasks/feature-extraction/spec/input.json +26 -0
- package/src/tasks/feature-extraction/spec/output.json +7 -0
- package/src/tasks/fill-mask/inference.ts +62 -0
- package/src/tasks/fill-mask/spec/input.json +38 -0
- package/src/tasks/fill-mask/spec/output.json +29 -0
- package/src/tasks/image-classification/inference.ts +51 -0
- package/src/tasks/image-classification/spec/input.json +34 -0
- package/src/tasks/image-classification/spec/output.json +10 -0
- package/src/tasks/image-segmentation/inference.ts +65 -0
- package/src/tasks/image-segmentation/spec/input.json +54 -0
- package/src/tasks/image-segmentation/spec/output.json +25 -0
- package/src/tasks/image-to-image/inference.ts +67 -0
- package/src/tasks/image-to-image/spec/input.json +54 -0
- package/src/tasks/image-to-image/spec/output.json +12 -0
- package/src/tasks/image-to-text/inference.ts +143 -0
- package/src/tasks/image-to-text/spec/input.json +34 -0
- package/src/tasks/image-to-text/spec/output.json +14 -0
- package/src/tasks/index.ts +5 -2
- package/src/tasks/mask-generation/about.md +65 -0
- package/src/tasks/mask-generation/data.ts +42 -5
- package/src/tasks/object-detection/inference.ts +62 -0
- package/src/tasks/object-detection/spec/input.json +30 -0
- package/src/tasks/object-detection/spec/output.json +46 -0
- package/src/tasks/placeholder/data.ts +3 -0
- package/src/tasks/placeholder/spec/input.json +35 -0
- package/src/tasks/placeholder/spec/output.json +17 -0
- package/src/tasks/question-answering/inference.ts +99 -0
- package/src/tasks/question-answering/spec/input.json +67 -0
- package/src/tasks/question-answering/spec/output.json +29 -0
- package/src/tasks/sentence-similarity/about.md +2 -2
- package/src/tasks/sentence-similarity/inference.ts +32 -0
- package/src/tasks/sentence-similarity/spec/input.json +40 -0
- package/src/tasks/sentence-similarity/spec/output.json +12 -0
- package/src/tasks/summarization/data.ts +1 -0
- package/src/tasks/summarization/inference.ts +59 -0
- package/src/tasks/summarization/spec/input.json +7 -0
- package/src/tasks/summarization/spec/output.json +7 -0
- package/src/tasks/table-question-answering/inference.ts +61 -0
- package/src/tasks/table-question-answering/spec/input.json +44 -0
- package/src/tasks/table-question-answering/spec/output.json +40 -0
- package/src/tasks/tabular-classification/about.md +1 -1
- package/src/tasks/tabular-regression/about.md +1 -1
- package/src/tasks/text-classification/about.md +1 -0
- package/src/tasks/text-classification/inference.ts +51 -0
- package/src/tasks/text-classification/spec/input.json +35 -0
- package/src/tasks/text-classification/spec/output.json +10 -0
- package/src/tasks/text-generation/about.md +24 -13
- package/src/tasks/text-generation/data.ts +22 -38
- package/src/tasks/text-generation/inference.ts +194 -0
- package/src/tasks/text-generation/spec/input.json +90 -0
- package/src/tasks/text-generation/spec/output.json +120 -0
- package/src/tasks/text-to-audio/inference.ts +143 -0
- package/src/tasks/text-to-audio/spec/input.json +31 -0
- package/src/tasks/text-to-audio/spec/output.json +17 -0
- package/src/tasks/text-to-image/about.md +11 -2
- package/src/tasks/text-to-image/data.ts +6 -2
- package/src/tasks/text-to-image/inference.ts +71 -0
- package/src/tasks/text-to-image/spec/input.json +59 -0
- package/src/tasks/text-to-image/spec/output.json +13 -0
- package/src/tasks/text-to-speech/about.md +4 -2
- package/src/tasks/text-to-speech/data.ts +1 -0
- package/src/tasks/text-to-speech/inference.ts +147 -0
- package/src/tasks/text-to-speech/spec/input.json +7 -0
- package/src/tasks/text-to-speech/spec/output.json +7 -0
- package/src/tasks/text2text-generation/inference.ts +55 -0
- package/src/tasks/text2text-generation/spec/input.json +55 -0
- package/src/tasks/text2text-generation/spec/output.json +14 -0
- package/src/tasks/token-classification/inference.ts +82 -0
- package/src/tasks/token-classification/spec/input.json +65 -0
- package/src/tasks/token-classification/spec/output.json +33 -0
- package/src/tasks/translation/data.ts +1 -0
- package/src/tasks/translation/inference.ts +59 -0
- package/src/tasks/translation/spec/input.json +7 -0
- package/src/tasks/translation/spec/output.json +7 -0
- package/src/tasks/video-classification/inference.ts +59 -0
- package/src/tasks/video-classification/spec/input.json +42 -0
- package/src/tasks/video-classification/spec/output.json +10 -0
- package/src/tasks/visual-question-answering/inference.ts +63 -0
- package/src/tasks/visual-question-answering/spec/input.json +41 -0
- package/src/tasks/visual-question-answering/spec/output.json +21 -0
- package/src/tasks/zero-shot-classification/inference.ts +67 -0
- package/src/tasks/zero-shot-classification/spec/input.json +50 -0
- package/src/tasks/zero-shot-classification/spec/output.json +10 -0
- package/src/tasks/zero-shot-image-classification/data.ts +8 -5
- package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
- package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
- package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
- package/src/tasks/zero-shot-object-detection/about.md +6 -0
- package/src/tasks/zero-shot-object-detection/data.ts +6 -1
- package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
- package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
- package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
- package/tsconfig.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type FeatureExtractionOutput = unknown[];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Inputs for Text Embedding inference
|
|
11
|
+
*/
|
|
12
|
+
export interface FeatureExtractionInput {
|
|
13
|
+
/**
|
|
14
|
+
* The text to get the embeddings of
|
|
15
|
+
*/
|
|
16
|
+
inputs: string;
|
|
17
|
+
/**
|
|
18
|
+
* Additional inference parameters
|
|
19
|
+
*/
|
|
20
|
+
parameters?: { [key: string]: unknown };
|
|
21
|
+
[property: string]: unknown;
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/feature-extraction/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Text Embedding inference",
|
|
5
|
+
"title": "FeatureExtractionInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The text to get the embeddings of",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"parameters": {
|
|
13
|
+
"description": "Additional inference parameters",
|
|
14
|
+
"$ref": "#/$defs/FeatureExtractionParameters"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"$defs": {
|
|
18
|
+
"FeatureExtractionParameters": {
|
|
19
|
+
"title": "FeatureExtractionParameters",
|
|
20
|
+
"description": "Additional inference parameters for Feature Extraction",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["inputs"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/feature-extraction/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "The embedding for the input text, as a nested list (tensor) of floats",
|
|
5
|
+
"type": "array",
|
|
6
|
+
"title": "FeatureExtractionOutput"
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Inputs for Fill Mask inference
|
|
8
|
+
*/
|
|
9
|
+
export interface FillMaskInput {
|
|
10
|
+
/**
|
|
11
|
+
* The text with masked tokens
|
|
12
|
+
*/
|
|
13
|
+
inputs: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional inference parameters
|
|
16
|
+
*/
|
|
17
|
+
parameters?: FillMaskParameters;
|
|
18
|
+
[property: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Additional inference parameters
|
|
22
|
+
*
|
|
23
|
+
* Additional inference parameters for Fill Mask
|
|
24
|
+
*/
|
|
25
|
+
export interface FillMaskParameters {
|
|
26
|
+
/**
|
|
27
|
+
* When passed, the model will limit the scores to the passed targets instead of looking up
|
|
28
|
+
* in the whole vocabulary. If the provided targets are not in the model vocab, they will be
|
|
29
|
+
* tokenized and the first resulting token will be used (with a warning, and that might be
|
|
30
|
+
* slower).
|
|
31
|
+
*/
|
|
32
|
+
targets?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* When passed, overrides the number of predictions to return.
|
|
35
|
+
*/
|
|
36
|
+
top_k?: number;
|
|
37
|
+
[property: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
export type FillMaskOutput = FillMaskOutputElement[];
|
|
40
|
+
/**
|
|
41
|
+
* Outputs of inference for the Fill Mask task
|
|
42
|
+
*/
|
|
43
|
+
export interface FillMaskOutputElement {
|
|
44
|
+
/**
|
|
45
|
+
* The corresponding probability
|
|
46
|
+
*/
|
|
47
|
+
score: number;
|
|
48
|
+
/**
|
|
49
|
+
* The corresponding input with the mask token prediction.
|
|
50
|
+
*/
|
|
51
|
+
sequence: string;
|
|
52
|
+
/**
|
|
53
|
+
* The predicted token id (to replace the masked one).
|
|
54
|
+
*/
|
|
55
|
+
token: number;
|
|
56
|
+
tokenStr: unknown;
|
|
57
|
+
/**
|
|
58
|
+
* The predicted token (to replace the masked one).
|
|
59
|
+
*/
|
|
60
|
+
token_str?: string;
|
|
61
|
+
[property: string]: unknown;
|
|
62
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/fill-mask/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Fill Mask inference",
|
|
5
|
+
"title": "FillMaskInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The text with masked tokens",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"parameters": {
|
|
13
|
+
"description": "Additional inference parameters",
|
|
14
|
+
"$ref": "#/$defs/FillMaskParameters"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"$defs": {
|
|
18
|
+
"FillMaskParameters": {
|
|
19
|
+
"title": "FillMaskParameters",
|
|
20
|
+
"description": "Additional inference parameters for Fill Mask",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"top_k": {
|
|
24
|
+
"type": "integer",
|
|
25
|
+
"description": "When passed, overrides the number of predictions to return."
|
|
26
|
+
},
|
|
27
|
+
"targets": {
|
|
28
|
+
"description": "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).",
|
|
29
|
+
"type": "array",
|
|
30
|
+
"items": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": ["inputs"]
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/fill-mask/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Fill Mask task",
|
|
5
|
+
"title": "FillMaskOutput",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"sequence": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The corresponding input with the mask token prediction."
|
|
13
|
+
},
|
|
14
|
+
"score": {
|
|
15
|
+
"type": "number",
|
|
16
|
+
"description": "The corresponding probability"
|
|
17
|
+
},
|
|
18
|
+
"token": {
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"description": "The predicted token id (to replace the masked one)."
|
|
21
|
+
},
|
|
22
|
+
"token_str": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The predicted token (to replace the masked one)."
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": ["sequence", "score", "token", "tokenStr"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Inputs for Image Classification inference
|
|
8
|
+
*/
|
|
9
|
+
export interface ImageClassificationInput {
|
|
10
|
+
/**
|
|
11
|
+
* The input image data
|
|
12
|
+
*/
|
|
13
|
+
inputs: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Additional inference parameters
|
|
16
|
+
*/
|
|
17
|
+
parameters?: ImageClassificationParameters;
|
|
18
|
+
[property: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Additional inference parameters
|
|
22
|
+
*
|
|
23
|
+
* Additional inference parameters for Image Classification
|
|
24
|
+
*/
|
|
25
|
+
export interface ImageClassificationParameters {
|
|
26
|
+
function_to_apply?: ClassificationOutputTransform;
|
|
27
|
+
/**
|
|
28
|
+
* When specified, limits the output to the top K most probable classes.
|
|
29
|
+
*/
|
|
30
|
+
top_k?: number;
|
|
31
|
+
[property: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The function to apply to the model outputs in order to retrieve the scores.
|
|
35
|
+
*/
|
|
36
|
+
export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none";
|
|
37
|
+
export type ImageClassificationOutput = ImageClassificationOutputElement[];
|
|
38
|
+
/**
|
|
39
|
+
* Outputs of inference for the Image Classification task
|
|
40
|
+
*/
|
|
41
|
+
export interface ImageClassificationOutputElement {
|
|
42
|
+
/**
|
|
43
|
+
* The predicted class label.
|
|
44
|
+
*/
|
|
45
|
+
label: string;
|
|
46
|
+
/**
|
|
47
|
+
* The corresponding probability.
|
|
48
|
+
*/
|
|
49
|
+
score: number;
|
|
50
|
+
[property: string]: unknown;
|
|
51
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-classification/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Image Classification inference",
|
|
5
|
+
"title": "ImageClassificationInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The input image data"
|
|
10
|
+
},
|
|
11
|
+
"parameters": {
|
|
12
|
+
"description": "Additional inference parameters",
|
|
13
|
+
"$ref": "#/$defs/ImageClassificationParameters"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"$defs": {
|
|
17
|
+
"ImageClassificationParameters": {
|
|
18
|
+
"title": "ImageClassificationParameters",
|
|
19
|
+
"description": "Additional inference parameters for Image Classification",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"function_to_apply": {
|
|
23
|
+
"title": "ImageClassificationOutputTransform",
|
|
24
|
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform"
|
|
25
|
+
},
|
|
26
|
+
"top_k": {
|
|
27
|
+
"type": "integer",
|
|
28
|
+
"description": "When specified, limits the output to the top K most probable classes."
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": ["inputs"]
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-classification/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Image Classification task",
|
|
5
|
+
"title": "ImageClassificationOutput",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Inputs for Image Segmentation inference
|
|
8
|
+
*/
|
|
9
|
+
export interface ImageSegmentationInput {
|
|
10
|
+
/**
|
|
11
|
+
* The input image data
|
|
12
|
+
*/
|
|
13
|
+
inputs: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Additional inference parameters
|
|
16
|
+
*/
|
|
17
|
+
parameters?: ImageSegmentationParameters;
|
|
18
|
+
[property: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Additional inference parameters
|
|
22
|
+
*
|
|
23
|
+
* Additional inference parameters for Image Segmentation
|
|
24
|
+
*/
|
|
25
|
+
export interface ImageSegmentationParameters {
|
|
26
|
+
/**
|
|
27
|
+
* Threshold to use when turning the predicted masks into binary values.
|
|
28
|
+
*/
|
|
29
|
+
mask_threshold?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Mask overlap threshold to eliminate small, disconnected segments.
|
|
32
|
+
*/
|
|
33
|
+
overlap_mask_area_threshold?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Segmentation task to be performed, depending on model capabilities.
|
|
36
|
+
*/
|
|
37
|
+
subtask?: ImageSegmentationSubtask;
|
|
38
|
+
/**
|
|
39
|
+
* Probability threshold to filter out predicted masks.
|
|
40
|
+
*/
|
|
41
|
+
threshold?: number;
|
|
42
|
+
[property: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
export type ImageSegmentationSubtask = "instance" | "panoptic" | "semantic";
|
|
45
|
+
export type ImageSegmentationOutput = ImageSegmentationOutputElement[];
|
|
46
|
+
/**
|
|
47
|
+
* Outputs of inference for the Image Segmentation task
|
|
48
|
+
*
|
|
49
|
+
* A predicted mask / segment
|
|
50
|
+
*/
|
|
51
|
+
export interface ImageSegmentationOutputElement {
|
|
52
|
+
/**
|
|
53
|
+
* The label of the predicted segment
|
|
54
|
+
*/
|
|
55
|
+
label: string;
|
|
56
|
+
/**
|
|
57
|
+
* The corresponding mask as a black-and-white image
|
|
58
|
+
*/
|
|
59
|
+
mask: unknown;
|
|
60
|
+
/**
|
|
61
|
+
* The score or confidence degreee the model has
|
|
62
|
+
*/
|
|
63
|
+
score?: number;
|
|
64
|
+
[property: string]: unknown;
|
|
65
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-segmentation/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Image Segmentation inference",
|
|
5
|
+
"title": "ImageSegmentationInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The input image data"
|
|
10
|
+
},
|
|
11
|
+
"parameters": {
|
|
12
|
+
"description": "Additional inference parameters",
|
|
13
|
+
"$ref": "#/$defs/ImageSegmentationParameters"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"$defs": {
|
|
17
|
+
"ImageSegmentationParameters": {
|
|
18
|
+
"title": "ImageSegmentationParameters",
|
|
19
|
+
"description": "Additional inference parameters for Image Segmentation",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"mask_threshold": {
|
|
23
|
+
"type": "number",
|
|
24
|
+
"description": "Threshold to use when turning the predicted masks into binary values."
|
|
25
|
+
},
|
|
26
|
+
"overlap_mask_area_threshold": {
|
|
27
|
+
"type": "number",
|
|
28
|
+
"description": "Mask overlap threshold to eliminate small, disconnected segments."
|
|
29
|
+
},
|
|
30
|
+
"subtask": {
|
|
31
|
+
"title": "ImageSegmentationSubtask",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Segmentation task to be performed, depending on model capabilities.",
|
|
34
|
+
"oneOf": [
|
|
35
|
+
{
|
|
36
|
+
"const": "instance"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"const": "panoptic"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"const": "semantic"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"threshold": {
|
|
47
|
+
"type": "number",
|
|
48
|
+
"description": "Probability threshold to filter out predicted masks."
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": ["inputs"]
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-segmentation/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Image Segmentation task",
|
|
5
|
+
"title": "ImageSegmentationOutput",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"description": "A predicted mask / segment",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"label": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The label of the predicted segment"
|
|
14
|
+
},
|
|
15
|
+
"mask": {
|
|
16
|
+
"description": "The corresponding mask as a black-and-white image"
|
|
17
|
+
},
|
|
18
|
+
"score": {
|
|
19
|
+
"type": "number",
|
|
20
|
+
"description": "The score or confidence degreee the model has"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": ["label", "mask"]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Inputs for Image To Image inference
|
|
9
|
+
*/
|
|
10
|
+
export interface ImageToImageInput {
|
|
11
|
+
/**
|
|
12
|
+
* The input image data
|
|
13
|
+
*/
|
|
14
|
+
inputs: unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Additional inference parameters
|
|
17
|
+
*/
|
|
18
|
+
parameters?: ImageToImageParameters;
|
|
19
|
+
[property: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Additional inference parameters
|
|
24
|
+
*
|
|
25
|
+
* Additional inference parameters for Image To Image
|
|
26
|
+
*/
|
|
27
|
+
export interface ImageToImageParameters {
|
|
28
|
+
/**
|
|
29
|
+
* For diffusion models. A higher guidance scale value encourages the model to generate
|
|
30
|
+
* images closely linked to the text prompt at the expense of lower image quality.
|
|
31
|
+
*/
|
|
32
|
+
guidance_scale?: number;
|
|
33
|
+
/**
|
|
34
|
+
* One or several prompt to guide what NOT to include in image generation.
|
|
35
|
+
*/
|
|
36
|
+
negative_prompt?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* For diffusion models. The number of denoising steps. More denoising steps usually lead to
|
|
39
|
+
* a higher quality image at the expense of slower inference.
|
|
40
|
+
*/
|
|
41
|
+
num_inference_steps?: number;
|
|
42
|
+
/**
|
|
43
|
+
* The size in pixel of the output image
|
|
44
|
+
*/
|
|
45
|
+
target_size?: TargetSize;
|
|
46
|
+
[property: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The size in pixel of the output image
|
|
51
|
+
*/
|
|
52
|
+
export interface TargetSize {
|
|
53
|
+
height: number;
|
|
54
|
+
width: number;
|
|
55
|
+
[property: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Outputs of inference for the Image To Image task
|
|
60
|
+
*/
|
|
61
|
+
export interface ImageToImageOutput {
|
|
62
|
+
/**
|
|
63
|
+
* The output image
|
|
64
|
+
*/
|
|
65
|
+
image?: unknown;
|
|
66
|
+
[property: string]: unknown;
|
|
67
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-to-image/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Image To Image inference",
|
|
5
|
+
"title": "ImageToImageInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The input image data"
|
|
10
|
+
},
|
|
11
|
+
"parameters": {
|
|
12
|
+
"description": "Additional inference parameters",
|
|
13
|
+
"$ref": "#/$defs/ImageToImageParameters"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"$defs": {
|
|
17
|
+
"ImageToImageParameters": {
|
|
18
|
+
"title": "ImageToImageParameters",
|
|
19
|
+
"description": "Additional inference parameters for Image To Image",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"guidance_scale": {
|
|
23
|
+
"type": "number",
|
|
24
|
+
"description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality."
|
|
25
|
+
},
|
|
26
|
+
"negative_prompt": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"description": "One or several prompt to guide what NOT to include in image generation."
|
|
32
|
+
},
|
|
33
|
+
"num_inference_steps": {
|
|
34
|
+
"type": "integer",
|
|
35
|
+
"description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
|
|
36
|
+
},
|
|
37
|
+
"target_size": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"description": "The size in pixel of the output image",
|
|
40
|
+
"properties": {
|
|
41
|
+
"width": {
|
|
42
|
+
"type": "integer"
|
|
43
|
+
},
|
|
44
|
+
"height": {
|
|
45
|
+
"type": "integer"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": ["width", "height"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": ["inputs"]
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/image-to-image/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Image To Image task",
|
|
5
|
+
"title": "ImageToImageOutput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"image": {
|
|
9
|
+
"description": "The output image"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|