@huggingface/tasks 0.11.11 → 0.11.13

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.
Files changed (76) hide show
  1. package/dist/index.cjs +146 -17
  2. package/dist/index.js +146 -17
  3. package/dist/src/dataset-libraries.d.ts +6 -0
  4. package/dist/src/dataset-libraries.d.ts.map +1 -1
  5. package/dist/src/hardware.d.ts +8 -0
  6. package/dist/src/hardware.d.ts.map +1 -1
  7. package/dist/src/model-libraries-snippets.d.ts +3 -0
  8. package/dist/src/model-libraries-snippets.d.ts.map +1 -1
  9. package/dist/src/model-libraries.d.ts +34 -2
  10. package/dist/src/model-libraries.d.ts.map +1 -1
  11. package/dist/src/pipelines.d.ts +12 -2
  12. package/dist/src/pipelines.d.ts.map +1 -1
  13. package/dist/src/snippets/curl.d.ts.map +1 -1
  14. package/dist/src/snippets/js.d.ts.map +1 -1
  15. package/dist/src/snippets/python.d.ts.map +1 -1
  16. package/dist/src/tasks/audio-classification/inference.d.ts +3 -2
  17. package/dist/src/tasks/audio-classification/inference.d.ts.map +1 -1
  18. package/dist/src/tasks/automatic-speech-recognition/inference.d.ts +3 -2
  19. package/dist/src/tasks/automatic-speech-recognition/inference.d.ts.map +1 -1
  20. package/dist/src/tasks/image-classification/inference.d.ts +3 -2
  21. package/dist/src/tasks/image-classification/inference.d.ts.map +1 -1
  22. package/dist/src/tasks/image-segmentation/inference.d.ts +10 -6
  23. package/dist/src/tasks/image-segmentation/inference.d.ts.map +1 -1
  24. package/dist/src/tasks/image-to-image/inference.d.ts +6 -5
  25. package/dist/src/tasks/image-to-image/inference.d.ts.map +1 -1
  26. package/dist/src/tasks/index.d.ts +1 -1
  27. package/dist/src/tasks/index.d.ts.map +1 -1
  28. package/dist/src/tasks/keypoint-detection/data.d.ts +4 -0
  29. package/dist/src/tasks/keypoint-detection/data.d.ts.map +1 -0
  30. package/dist/src/tasks/object-detection/inference.d.ts +17 -4
  31. package/dist/src/tasks/object-detection/inference.d.ts.map +1 -1
  32. package/dist/src/tasks/summarization/inference.d.ts +13 -12
  33. package/dist/src/tasks/summarization/inference.d.ts.map +1 -1
  34. package/dist/src/tasks/text-to-image/inference.d.ts +2 -2
  35. package/dist/src/tasks/translation/inference.d.ts +21 -10
  36. package/dist/src/tasks/translation/inference.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/dataset-libraries.ts +6 -0
  39. package/src/hardware.ts +8 -0
  40. package/src/local-apps.ts +1 -1
  41. package/src/model-libraries-snippets.ts +87 -6
  42. package/src/model-libraries.ts +32 -0
  43. package/src/pipelines.ts +12 -0
  44. package/src/snippets/curl.ts +3 -6
  45. package/src/snippets/js.ts +1 -2
  46. package/src/snippets/python.ts +1 -2
  47. package/src/tasks/audio-classification/inference.ts +3 -2
  48. package/src/tasks/audio-classification/spec/input.json +2 -1
  49. package/src/tasks/audio-classification/spec/output.json +1 -0
  50. package/src/tasks/automatic-speech-recognition/inference.ts +3 -2
  51. package/src/tasks/automatic-speech-recognition/spec/input.json +2 -1
  52. package/src/tasks/common-definitions.json +3 -20
  53. package/src/tasks/image-classification/inference.ts +3 -2
  54. package/src/tasks/image-classification/spec/input.json +2 -1
  55. package/src/tasks/image-classification/spec/output.json +1 -0
  56. package/src/tasks/image-segmentation/inference.ts +10 -6
  57. package/src/tasks/image-segmentation/spec/input.json +3 -12
  58. package/src/tasks/image-segmentation/spec/output.json +4 -3
  59. package/src/tasks/image-to-image/inference.ts +6 -5
  60. package/src/tasks/image-to-image/spec/input.json +3 -2
  61. package/src/tasks/image-to-image/spec/output.json +1 -1
  62. package/src/tasks/index.ts +3 -6
  63. package/src/tasks/keypoint-detection/about.md +59 -0
  64. package/src/tasks/keypoint-detection/data.ts +46 -0
  65. package/src/tasks/object-detection/inference.ts +17 -4
  66. package/src/tasks/object-detection/spec/input.json +2 -1
  67. package/src/tasks/object-detection/spec/output.json +10 -6
  68. package/src/tasks/summarization/inference.ts +13 -12
  69. package/src/tasks/summarization/spec/input.json +37 -2
  70. package/src/tasks/text-classification/spec/output.json +1 -0
  71. package/src/tasks/text-to-image/inference.ts +2 -2
  72. package/src/tasks/text-to-image/spec/input.json +1 -1
  73. package/src/tasks/text-to-image/spec/output.json +1 -1
  74. package/src/tasks/translation/inference.ts +21 -10
  75. package/src/tasks/translation/spec/input.json +45 -2
  76. package/src/tasks/zero-shot-classification/spec/output.json +1 -0
@@ -8,9 +8,10 @@
8
8
  */
9
9
  export interface ObjectDetectionInput {
10
10
  /**
11
- * The input image data
11
+ * The input image data as a base64-encoded string. If no `parameters` are provided, you can
12
+ * also provide the image data as a raw bytes payload.
12
13
  */
13
- inputs: unknown;
14
+ inputs: string;
14
15
  /**
15
16
  * Additional inference parameters
16
17
  */
@@ -34,9 +35,21 @@ export interface ObjectDetectionParameters {
34
35
  * image.
35
36
  */
36
37
  export interface BoundingBox {
38
+ /**
39
+ * The x-coordinate of the bottom-right corner of the bounding box.
40
+ */
37
41
  xmax: number;
42
+ /**
43
+ * The x-coordinate of the top-left corner of the bounding box.
44
+ */
38
45
  xmin: number;
46
+ /**
47
+ * The y-coordinate of the bottom-right corner of the bounding box.
48
+ */
39
49
  ymax: number;
50
+ /**
51
+ * The y-coordinate of the top-left corner of the bounding box.
52
+ */
40
53
  ymin: number;
41
54
  [property: string]: unknown;
42
55
  }
@@ -51,11 +64,11 @@ export interface ObjectDetectionOutputElement {
51
64
  */
52
65
  box: BoundingBox;
53
66
  /**
54
- * The predicted label for the bounding box
67
+ * The predicted label for the bounding box.
55
68
  */
56
69
  label: string;
57
70
  /**
58
- * The associated score / probability
71
+ * The associated score / probability.
59
72
  */
60
73
  score: number;
61
74
  [property: string]: unknown;
@@ -6,7 +6,8 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "inputs": {
9
- "description": "The input image data"
9
+ "type": "string",
10
+ "description": "The input image data as a base64-encoded string. If no `parameters` are provided, you can also provide the image data as a raw bytes payload."
10
11
  },
11
12
  "parameters": {
12
13
  "description": "Additional inference parameters",
@@ -9,11 +9,11 @@
9
9
  "properties": {
10
10
  "label": {
11
11
  "type": "string",
12
- "description": "The predicted label for the bounding box"
12
+ "description": "The predicted label for the bounding box."
13
13
  },
14
14
  "score": {
15
15
  "type": "number",
16
- "description": "The associated score / probability"
16
+ "description": "The associated score / probability."
17
17
  },
18
18
  "box": {
19
19
  "$ref": "#/$defs/BoundingBox",
@@ -28,16 +28,20 @@
28
28
  "title": "BoundingBox",
29
29
  "properties": {
30
30
  "xmin": {
31
- "type": "integer"
31
+ "type": "integer",
32
+ "description": "The x-coordinate of the top-left corner of the bounding box."
32
33
  },
33
34
  "xmax": {
34
- "type": "integer"
35
+ "type": "integer",
36
+ "description": "The x-coordinate of the bottom-right corner of the bounding box."
35
37
  },
36
38
  "ymin": {
37
- "type": "integer"
39
+ "type": "integer",
40
+ "description": "The y-coordinate of the top-left corner of the bounding box."
38
41
  },
39
42
  "ymax": {
40
- "type": "integer"
43
+ "type": "integer",
44
+ "description": "The y-coordinate of the bottom-right corner of the bounding box."
41
45
  }
42
46
  },
43
47
  "required": ["xmin", "xmax", "ymin", "ymax"]
@@ -6,43 +6,44 @@
6
6
 
7
7
  /**
8
8
  * Inputs for Summarization inference
9
- *
10
- * Inputs for Text2text Generation inference
11
9
  */
12
10
  export interface SummarizationInput {
13
11
  /**
14
- * The input text data
12
+ * The input text to summarize.
15
13
  */
16
14
  inputs: string;
17
15
  /**
18
- * Additional inference parameters
16
+ * Additional inference parameters.
19
17
  */
20
- parameters?: Text2TextGenerationParameters;
18
+ parameters?: SummarizationParameters;
21
19
  [property: string]: unknown;
22
20
  }
23
21
 
24
22
  /**
25
- * Additional inference parameters
23
+ * Additional inference parameters.
26
24
  *
27
- * Additional inference parameters for Text2text Generation
25
+ * Additional inference parameters for summarization.
28
26
  */
29
- export interface Text2TextGenerationParameters {
27
+ export interface SummarizationParameters {
30
28
  /**
31
29
  * Whether to clean up the potential extra spaces in the text output.
32
30
  */
33
31
  clean_up_tokenization_spaces?: boolean;
34
32
  /**
35
- * Additional parametrization of the text generation algorithm
33
+ * Additional parametrization of the text generation algorithm.
36
34
  */
37
35
  generate_parameters?: { [key: string]: unknown };
38
36
  /**
39
- * The truncation strategy to use
37
+ * The truncation strategy to use.
40
38
  */
41
- truncation?: Text2TextGenerationTruncationStrategy;
39
+ truncation?: SummarizationTruncationStrategy;
42
40
  [property: string]: unknown;
43
41
  }
44
42
 
45
- export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
43
+ /**
44
+ * The truncation strategy to use.
45
+ */
46
+ export type SummarizationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
46
47
 
47
48
  /**
48
49
  * Outputs of inference for the Summarization task
@@ -1,7 +1,42 @@
1
1
  {
2
- "$ref": "/inference/schemas/text2text-generation/input.json",
3
2
  "$id": "/inference/schemas/summarization/input.json",
4
3
  "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Summarization inference",
5
5
  "title": "SummarizationInput",
6
- "description": "Inputs for Summarization inference"
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The input text to summarize.",
10
+ "type": "string"
11
+ },
12
+ "parameters": {
13
+ "description": "Additional inference parameters.",
14
+ "$ref": "#/$defs/SummarizationParameters"
15
+ }
16
+ },
17
+ "$defs": {
18
+ "SummarizationParameters": {
19
+ "title": "SummarizationParameters",
20
+ "description": "Additional inference parameters for summarization.",
21
+ "type": "object",
22
+ "properties": {
23
+ "clean_up_tokenization_spaces": {
24
+ "type": "boolean",
25
+ "description": "Whether to clean up the potential extra spaces in the text output."
26
+ },
27
+ "truncation": {
28
+ "title": "SummarizationTruncationStrategy",
29
+ "type": "string",
30
+ "description": "The truncation strategy to use.",
31
+ "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"]
32
+ },
33
+ "generate_parameters": {
34
+ "title": "generateParameters",
35
+ "type": "object",
36
+ "description": "Additional parametrization of the text generation algorithm."
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "required": ["inputs"]
7
42
  }
@@ -5,6 +5,7 @@
5
5
  "title": "TextClassificationOutput",
6
6
  "type": "array",
7
7
  "items": {
8
+ "type": "object",
8
9
  "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput"
9
10
  }
10
11
  }
@@ -9,7 +9,7 @@
9
9
  */
10
10
  export interface TextToImageInput {
11
11
  /**
12
- * The input text data (sometimes called "prompt"
12
+ * The input text data (sometimes called "prompt")
13
13
  */
14
14
  inputs: string;
15
15
  /**
@@ -64,7 +64,7 @@ export interface TargetSize {
64
64
  */
65
65
  export interface TextToImageOutput {
66
66
  /**
67
- * The generated image
67
+ * The generated image returned as raw bytes in the payload.
68
68
  */
69
69
  image: unknown;
70
70
  [property: string]: unknown;
@@ -6,7 +6,7 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "inputs": {
9
- "description": "The input text data (sometimes called \"prompt\"",
9
+ "description": "The input text data (sometimes called \"prompt\")",
10
10
  "type": "string"
11
11
  },
12
12
  "parameters": {
@@ -6,7 +6,7 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "image": {
9
- "description": "The generated image"
9
+ "description": "The generated image returned as raw bytes in the payload."
10
10
  }
11
11
  },
12
12
  "required": ["image"]
@@ -6,43 +6,54 @@
6
6
 
7
7
  /**
8
8
  * Inputs for Translation inference
9
- *
10
- * Inputs for Text2text Generation inference
11
9
  */
12
10
  export interface TranslationInput {
13
11
  /**
14
- * The input text data
12
+ * The text to translate.
15
13
  */
16
14
  inputs: string;
17
15
  /**
18
16
  * Additional inference parameters
19
17
  */
20
- parameters?: Text2TextGenerationParameters;
18
+ parameters?: TranslationParameters;
21
19
  [property: string]: unknown;
22
20
  }
23
21
 
24
22
  /**
25
23
  * Additional inference parameters
26
24
  *
27
- * Additional inference parameters for Text2text Generation
25
+ * Additional inference parameters for Translation
28
26
  */
29
- export interface Text2TextGenerationParameters {
27
+ export interface TranslationParameters {
30
28
  /**
31
29
  * Whether to clean up the potential extra spaces in the text output.
32
30
  */
33
31
  clean_up_tokenization_spaces?: boolean;
34
32
  /**
35
- * Additional parametrization of the text generation algorithm
33
+ * Additional parametrization of the text generation algorithm.
36
34
  */
37
35
  generate_parameters?: { [key: string]: unknown };
38
36
  /**
39
- * The truncation strategy to use
37
+ * The source language of the text. Required for models that can translate from multiple
38
+ * languages.
39
+ */
40
+ src_lang?: string;
41
+ /**
42
+ * Target language to translate to. Required for models that can translate to multiple
43
+ * languages.
40
44
  */
41
- truncation?: Text2TextGenerationTruncationStrategy;
45
+ tgt_lang?: string;
46
+ /**
47
+ * The truncation strategy to use.
48
+ */
49
+ truncation?: TranslationTruncationStrategy;
42
50
  [property: string]: unknown;
43
51
  }
44
52
 
45
- export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
53
+ /**
54
+ * The truncation strategy to use.
55
+ */
56
+ export type TranslationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
46
57
 
47
58
  /**
48
59
  * Outputs of inference for the Translation task
@@ -1,7 +1,50 @@
1
1
  {
2
- "$ref": "/inference/schemas/text2text-generation/input.json",
3
2
  "$id": "/inference/schemas/translation/input.json",
4
3
  "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Translation inference",
5
5
  "title": "TranslationInput",
6
- "description": "Inputs for Translation inference"
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The text to translate.",
10
+ "type": "string"
11
+ },
12
+ "parameters": {
13
+ "description": "Additional inference parameters",
14
+ "$ref": "#/$defs/TranslationParameters"
15
+ }
16
+ },
17
+ "$defs": {
18
+ "TranslationParameters": {
19
+ "title": "TranslationParameters",
20
+ "description": "Additional inference parameters for Translation",
21
+ "type": "object",
22
+ "properties": {
23
+ "src_lang": {
24
+ "type": "string",
25
+ "description": "The source language of the text. Required for models that can translate from multiple languages."
26
+ },
27
+ "tgt_lang": {
28
+ "type": "string",
29
+ "description": "Target language to translate to. Required for models that can translate to multiple languages."
30
+ },
31
+ "clean_up_tokenization_spaces": {
32
+ "type": "boolean",
33
+ "description": "Whether to clean up the potential extra spaces in the text output."
34
+ },
35
+ "truncation": {
36
+ "title": "TranslationTruncationStrategy",
37
+ "type": "string",
38
+ "description": "The truncation strategy to use.",
39
+ "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"]
40
+ },
41
+ "generate_parameters": {
42
+ "title": "generateParameters",
43
+ "type": "object",
44
+ "description": "Additional parametrization of the text generation algorithm."
45
+ }
46
+ }
47
+ }
48
+ },
49
+ "required": ["inputs"]
7
50
  }
@@ -5,6 +5,7 @@
5
5
  "title": "ZeroShotClassificationOutput",
6
6
  "type": "array",
7
7
  "items": {
8
+ "type": "object",
8
9
  "$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput"
9
10
  }
10
11
  }