@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.
Files changed (123) hide show
  1. package/README.md +1 -1
  2. package/dist/{index.mjs → index.cjs} +2695 -2497
  3. package/dist/index.d.ts +427 -65
  4. package/dist/index.js +2660 -2532
  5. package/package.json +13 -8
  6. package/src/index.ts +2 -5
  7. package/src/library-to-tasks.ts +1 -1
  8. package/src/model-data.ts +1 -1
  9. package/src/model-libraries-downloads.ts +20 -0
  10. package/src/{library-ui-elements.ts → model-libraries-snippets.ts} +50 -296
  11. package/src/model-libraries.ts +375 -44
  12. package/src/pipelines.ts +1 -1
  13. package/src/tasks/audio-classification/about.md +1 -1
  14. package/src/tasks/audio-classification/inference.ts +51 -0
  15. package/src/tasks/audio-classification/spec/input.json +34 -0
  16. package/src/tasks/audio-classification/spec/output.json +10 -0
  17. package/src/tasks/audio-to-audio/about.md +1 -1
  18. package/src/tasks/automatic-speech-recognition/about.md +4 -2
  19. package/src/tasks/automatic-speech-recognition/inference.ts +159 -0
  20. package/src/tasks/automatic-speech-recognition/spec/input.json +34 -0
  21. package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
  22. package/src/tasks/common-definitions.json +117 -0
  23. package/src/tasks/depth-estimation/data.ts +8 -4
  24. package/src/tasks/depth-estimation/inference.ts +35 -0
  25. package/src/tasks/depth-estimation/spec/input.json +25 -0
  26. package/src/tasks/depth-estimation/spec/output.json +16 -0
  27. package/src/tasks/document-question-answering/inference.ts +110 -0
  28. package/src/tasks/document-question-answering/spec/input.json +85 -0
  29. package/src/tasks/document-question-answering/spec/output.json +36 -0
  30. package/src/tasks/feature-extraction/inference.ts +22 -0
  31. package/src/tasks/feature-extraction/spec/input.json +26 -0
  32. package/src/tasks/feature-extraction/spec/output.json +7 -0
  33. package/src/tasks/fill-mask/inference.ts +62 -0
  34. package/src/tasks/fill-mask/spec/input.json +38 -0
  35. package/src/tasks/fill-mask/spec/output.json +29 -0
  36. package/src/tasks/image-classification/inference.ts +51 -0
  37. package/src/tasks/image-classification/spec/input.json +34 -0
  38. package/src/tasks/image-classification/spec/output.json +10 -0
  39. package/src/tasks/image-segmentation/inference.ts +65 -0
  40. package/src/tasks/image-segmentation/spec/input.json +54 -0
  41. package/src/tasks/image-segmentation/spec/output.json +25 -0
  42. package/src/tasks/image-to-image/inference.ts +67 -0
  43. package/src/tasks/image-to-image/spec/input.json +54 -0
  44. package/src/tasks/image-to-image/spec/output.json +12 -0
  45. package/src/tasks/image-to-text/inference.ts +143 -0
  46. package/src/tasks/image-to-text/spec/input.json +34 -0
  47. package/src/tasks/image-to-text/spec/output.json +14 -0
  48. package/src/tasks/index.ts +5 -2
  49. package/src/tasks/mask-generation/about.md +65 -0
  50. package/src/tasks/mask-generation/data.ts +42 -5
  51. package/src/tasks/object-detection/inference.ts +62 -0
  52. package/src/tasks/object-detection/spec/input.json +30 -0
  53. package/src/tasks/object-detection/spec/output.json +46 -0
  54. package/src/tasks/placeholder/data.ts +3 -0
  55. package/src/tasks/placeholder/spec/input.json +35 -0
  56. package/src/tasks/placeholder/spec/output.json +17 -0
  57. package/src/tasks/question-answering/inference.ts +99 -0
  58. package/src/tasks/question-answering/spec/input.json +67 -0
  59. package/src/tasks/question-answering/spec/output.json +29 -0
  60. package/src/tasks/sentence-similarity/about.md +2 -2
  61. package/src/tasks/sentence-similarity/inference.ts +32 -0
  62. package/src/tasks/sentence-similarity/spec/input.json +40 -0
  63. package/src/tasks/sentence-similarity/spec/output.json +12 -0
  64. package/src/tasks/summarization/data.ts +1 -0
  65. package/src/tasks/summarization/inference.ts +59 -0
  66. package/src/tasks/summarization/spec/input.json +7 -0
  67. package/src/tasks/summarization/spec/output.json +7 -0
  68. package/src/tasks/table-question-answering/inference.ts +61 -0
  69. package/src/tasks/table-question-answering/spec/input.json +44 -0
  70. package/src/tasks/table-question-answering/spec/output.json +40 -0
  71. package/src/tasks/tabular-classification/about.md +1 -1
  72. package/src/tasks/tabular-regression/about.md +1 -1
  73. package/src/tasks/text-classification/about.md +1 -0
  74. package/src/tasks/text-classification/inference.ts +51 -0
  75. package/src/tasks/text-classification/spec/input.json +35 -0
  76. package/src/tasks/text-classification/spec/output.json +10 -0
  77. package/src/tasks/text-generation/about.md +24 -13
  78. package/src/tasks/text-generation/data.ts +22 -38
  79. package/src/tasks/text-generation/inference.ts +194 -0
  80. package/src/tasks/text-generation/spec/input.json +90 -0
  81. package/src/tasks/text-generation/spec/output.json +120 -0
  82. package/src/tasks/text-to-audio/inference.ts +143 -0
  83. package/src/tasks/text-to-audio/spec/input.json +31 -0
  84. package/src/tasks/text-to-audio/spec/output.json +17 -0
  85. package/src/tasks/text-to-image/about.md +11 -2
  86. package/src/tasks/text-to-image/data.ts +6 -2
  87. package/src/tasks/text-to-image/inference.ts +71 -0
  88. package/src/tasks/text-to-image/spec/input.json +59 -0
  89. package/src/tasks/text-to-image/spec/output.json +13 -0
  90. package/src/tasks/text-to-speech/about.md +4 -2
  91. package/src/tasks/text-to-speech/data.ts +1 -0
  92. package/src/tasks/text-to-speech/inference.ts +147 -0
  93. package/src/tasks/text-to-speech/spec/input.json +7 -0
  94. package/src/tasks/text-to-speech/spec/output.json +7 -0
  95. package/src/tasks/text2text-generation/inference.ts +55 -0
  96. package/src/tasks/text2text-generation/spec/input.json +55 -0
  97. package/src/tasks/text2text-generation/spec/output.json +14 -0
  98. package/src/tasks/token-classification/inference.ts +82 -0
  99. package/src/tasks/token-classification/spec/input.json +65 -0
  100. package/src/tasks/token-classification/spec/output.json +33 -0
  101. package/src/tasks/translation/data.ts +1 -0
  102. package/src/tasks/translation/inference.ts +59 -0
  103. package/src/tasks/translation/spec/input.json +7 -0
  104. package/src/tasks/translation/spec/output.json +7 -0
  105. package/src/tasks/video-classification/inference.ts +59 -0
  106. package/src/tasks/video-classification/spec/input.json +42 -0
  107. package/src/tasks/video-classification/spec/output.json +10 -0
  108. package/src/tasks/visual-question-answering/inference.ts +63 -0
  109. package/src/tasks/visual-question-answering/spec/input.json +41 -0
  110. package/src/tasks/visual-question-answering/spec/output.json +21 -0
  111. package/src/tasks/zero-shot-classification/inference.ts +67 -0
  112. package/src/tasks/zero-shot-classification/spec/input.json +50 -0
  113. package/src/tasks/zero-shot-classification/spec/output.json +10 -0
  114. package/src/tasks/zero-shot-image-classification/data.ts +8 -5
  115. package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
  116. package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
  117. package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
  118. package/src/tasks/zero-shot-object-detection/about.md +6 -0
  119. package/src/tasks/zero-shot-object-detection/data.ts +6 -1
  120. package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
  121. package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
  122. package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
  123. package/tsconfig.json +3 -3
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Inference code generated from the JSON schema spec in ./spec
3
+ *
4
+ * Using src/scripts/inference-codegen
5
+ */
6
+ /**
7
+ * Inputs for Zero Shot Object Detection inference
8
+ */
9
+ export interface ZeroShotObjectDetectionInput {
10
+ /**
11
+ * The input image data, with candidate labels
12
+ */
13
+ inputs: ZeroShotObjectDetectionInputData;
14
+ /**
15
+ * Additional inference parameters
16
+ */
17
+ parameters?: {
18
+ [key: string]: unknown;
19
+ };
20
+ [property: string]: unknown;
21
+ }
22
+ /**
23
+ * The input image data, with candidate labels
24
+ */
25
+ export interface ZeroShotObjectDetectionInputData {
26
+ /**
27
+ * The candidate labels for this image
28
+ */
29
+ candidateLabels: string[];
30
+ /**
31
+ * The image data to generate bounding boxes from
32
+ */
33
+ image: unknown;
34
+ [property: string]: unknown;
35
+ }
36
+ /**
37
+ * The predicted bounding box. Coordinates are relative to the top left corner of the input
38
+ * image.
39
+ */
40
+ export interface BoundingBox {
41
+ xmax: number;
42
+ xmin: number;
43
+ ymax: number;
44
+ ymin: number;
45
+ [property: string]: unknown;
46
+ }
47
+ export type ZeroShotObjectDetectionOutput = ZeroShotObjectDetectionOutputElement[];
48
+ /**
49
+ * Outputs of inference for the Zero Shot Object Detection task
50
+ */
51
+ export interface ZeroShotObjectDetectionOutputElement {
52
+ /**
53
+ * The predicted bounding box. Coordinates are relative to the top left corner of the input
54
+ * image.
55
+ */
56
+ box: BoundingBox;
57
+ /**
58
+ * A candidate label
59
+ */
60
+ label: string;
61
+ /**
62
+ * The associated score / probability
63
+ */
64
+ score: number;
65
+ [property: string]: unknown;
66
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$id": "/inference/schemas/zero-shot-object-detection/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Zero Shot Object Detection inference",
5
+ "title": "ZeroShotObjectDetectionInput",
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The input image data, with candidate labels",
10
+ "type": "object",
11
+ "title": "ZeroShotObjectDetectionInputData",
12
+ "properties": {
13
+ "image": {
14
+ "description": "The image data to generate bounding boxes from"
15
+ },
16
+ "candidateLabels": {
17
+ "description": "The candidate labels for this image",
18
+ "type": "array",
19
+ "items": {
20
+ "type": "string"
21
+ }
22
+ }
23
+ },
24
+ "required": ["image", "candidateLabels"]
25
+ },
26
+ "parameters": {
27
+ "description": "Additional inference parameters",
28
+ "$ref": "#/$defs/ZeroShotObjectDetectionParameters"
29
+ }
30
+ },
31
+ "$defs": {
32
+ "ZeroShotObjectDetectionParameters": {
33
+ "title": "ZeroShotObjectDetectionParameters",
34
+ "description": "Additional inference parameters for Zero Shot Object Detection",
35
+ "type": "object",
36
+ "properties": {}
37
+ }
38
+ },
39
+ "required": ["inputs"]
40
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$id": "/inference/schemas/zero-shot-object-detection/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs of inference for the Zero Shot Object Detection task",
5
+ "title": "ZeroShotObjectDetectionOutput",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "object",
9
+ "title": "ZeroShotObjectDetectionOutputElement",
10
+ "properties": {
11
+ "label": {
12
+ "type": "string",
13
+ "description": "A candidate label"
14
+ },
15
+ "score": {
16
+ "type": "number",
17
+ "description": "The associated score / probability"
18
+ },
19
+ "box": {
20
+ "$ref": "#/$defs/BoundingBox",
21
+ "description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image."
22
+ }
23
+ },
24
+ "required": ["box", "label", "score"]
25
+ },
26
+ "$defs": {
27
+ "BoundingBox": {
28
+ "title": "BoundingBox",
29
+ "type": "object",
30
+ "properties": {
31
+ "xmin": {
32
+ "type": "integer"
33
+ },
34
+ "xmax": {
35
+ "type": "integer"
36
+ },
37
+ "ymin": {
38
+ "type": "integer"
39
+ },
40
+ "ymax": {
41
+ "type": "integer"
42
+ }
43
+ },
44
+ "required": ["xmin", "xmax", "ymin", "ymax"]
45
+ }
46
+ }
47
+ }
package/tsconfig.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "compilerOptions": {
3
3
  "allowSyntheticDefaultImports": true,
4
4
  "lib": ["ES2022", "DOM"],
5
- "module": "CommonJS",
5
+ "module": "ESNext",
6
+ "target": "ESNext",
6
7
  "moduleResolution": "node",
7
- "target": "ES2022",
8
8
  "forceConsistentCasingInFileNames": true,
9
9
  "strict": true,
10
10
  "noImplicitAny": true,
@@ -13,6 +13,6 @@
13
13
  "noImplicitOverride": true,
14
14
  "outDir": "./dist"
15
15
  },
16
- "include": ["src"],
16
+ "include": ["src", "scripts"],
17
17
  "exclude": ["dist"]
18
18
  }