@huggingface/tasks 0.13.1-test → 0.13.1-test2

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 (198) hide show
  1. package/package.json +4 -2
  2. package/src/dataset-libraries.ts +89 -0
  3. package/src/default-widget-inputs.ts +718 -0
  4. package/src/gguf.ts +40 -0
  5. package/src/hardware.ts +482 -0
  6. package/src/index.ts +59 -0
  7. package/src/library-to-tasks.ts +76 -0
  8. package/src/local-apps.ts +412 -0
  9. package/src/model-data.ts +149 -0
  10. package/src/model-libraries-downloads.ts +18 -0
  11. package/src/model-libraries-snippets.ts +1128 -0
  12. package/src/model-libraries.ts +820 -0
  13. package/src/pipelines.ts +698 -0
  14. package/src/snippets/common.ts +39 -0
  15. package/src/snippets/curl.spec.ts +94 -0
  16. package/src/snippets/curl.ts +120 -0
  17. package/src/snippets/index.ts +7 -0
  18. package/src/snippets/inputs.ts +167 -0
  19. package/src/snippets/js.spec.ts +148 -0
  20. package/src/snippets/js.ts +305 -0
  21. package/src/snippets/python.spec.ts +144 -0
  22. package/src/snippets/python.ts +321 -0
  23. package/src/snippets/types.ts +16 -0
  24. package/src/tasks/audio-classification/about.md +86 -0
  25. package/src/tasks/audio-classification/data.ts +81 -0
  26. package/src/tasks/audio-classification/inference.ts +52 -0
  27. package/src/tasks/audio-classification/spec/input.json +35 -0
  28. package/src/tasks/audio-classification/spec/output.json +11 -0
  29. package/src/tasks/audio-to-audio/about.md +56 -0
  30. package/src/tasks/audio-to-audio/data.ts +70 -0
  31. package/src/tasks/automatic-speech-recognition/about.md +90 -0
  32. package/src/tasks/automatic-speech-recognition/data.ts +82 -0
  33. package/src/tasks/automatic-speech-recognition/inference.ts +160 -0
  34. package/src/tasks/automatic-speech-recognition/spec/input.json +35 -0
  35. package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
  36. package/src/tasks/chat-completion/inference.ts +322 -0
  37. package/src/tasks/chat-completion/spec/input.json +350 -0
  38. package/src/tasks/chat-completion/spec/output.json +206 -0
  39. package/src/tasks/chat-completion/spec/stream_output.json +213 -0
  40. package/src/tasks/common-definitions.json +100 -0
  41. package/src/tasks/depth-estimation/about.md +45 -0
  42. package/src/tasks/depth-estimation/data.ts +70 -0
  43. package/src/tasks/depth-estimation/inference.ts +35 -0
  44. package/src/tasks/depth-estimation/spec/input.json +25 -0
  45. package/src/tasks/depth-estimation/spec/output.json +16 -0
  46. package/src/tasks/document-question-answering/about.md +53 -0
  47. package/src/tasks/document-question-answering/data.ts +85 -0
  48. package/src/tasks/document-question-answering/inference.ts +110 -0
  49. package/src/tasks/document-question-answering/spec/input.json +85 -0
  50. package/src/tasks/document-question-answering/spec/output.json +36 -0
  51. package/src/tasks/feature-extraction/about.md +72 -0
  52. package/src/tasks/feature-extraction/data.ts +57 -0
  53. package/src/tasks/feature-extraction/inference.ts +40 -0
  54. package/src/tasks/feature-extraction/spec/input.json +47 -0
  55. package/src/tasks/feature-extraction/spec/output.json +15 -0
  56. package/src/tasks/fill-mask/about.md +51 -0
  57. package/src/tasks/fill-mask/data.ts +79 -0
  58. package/src/tasks/fill-mask/inference.ts +62 -0
  59. package/src/tasks/fill-mask/spec/input.json +38 -0
  60. package/src/tasks/fill-mask/spec/output.json +29 -0
  61. package/src/tasks/image-classification/about.md +50 -0
  62. package/src/tasks/image-classification/data.ts +88 -0
  63. package/src/tasks/image-classification/inference.ts +52 -0
  64. package/src/tasks/image-classification/spec/input.json +35 -0
  65. package/src/tasks/image-classification/spec/output.json +11 -0
  66. package/src/tasks/image-feature-extraction/about.md +23 -0
  67. package/src/tasks/image-feature-extraction/data.ts +59 -0
  68. package/src/tasks/image-segmentation/about.md +63 -0
  69. package/src/tasks/image-segmentation/data.ts +99 -0
  70. package/src/tasks/image-segmentation/inference.ts +69 -0
  71. package/src/tasks/image-segmentation/spec/input.json +45 -0
  72. package/src/tasks/image-segmentation/spec/output.json +26 -0
  73. package/src/tasks/image-text-to-text/about.md +76 -0
  74. package/src/tasks/image-text-to-text/data.ts +102 -0
  75. package/src/tasks/image-to-3d/about.md +62 -0
  76. package/src/tasks/image-to-3d/data.ts +75 -0
  77. package/src/tasks/image-to-image/about.md +129 -0
  78. package/src/tasks/image-to-image/data.ts +101 -0
  79. package/src/tasks/image-to-image/inference.ts +68 -0
  80. package/src/tasks/image-to-image/spec/input.json +55 -0
  81. package/src/tasks/image-to-image/spec/output.json +12 -0
  82. package/src/tasks/image-to-text/about.md +61 -0
  83. package/src/tasks/image-to-text/data.ts +82 -0
  84. package/src/tasks/image-to-text/inference.ts +143 -0
  85. package/src/tasks/image-to-text/spec/input.json +34 -0
  86. package/src/tasks/image-to-text/spec/output.json +14 -0
  87. package/src/tasks/index.ts +312 -0
  88. package/src/tasks/keypoint-detection/about.md +57 -0
  89. package/src/tasks/keypoint-detection/data.ts +50 -0
  90. package/src/tasks/mask-generation/about.md +65 -0
  91. package/src/tasks/mask-generation/data.ts +55 -0
  92. package/src/tasks/object-detection/about.md +37 -0
  93. package/src/tasks/object-detection/data.ts +86 -0
  94. package/src/tasks/object-detection/inference.ts +75 -0
  95. package/src/tasks/object-detection/spec/input.json +31 -0
  96. package/src/tasks/object-detection/spec/output.json +50 -0
  97. package/src/tasks/placeholder/about.md +15 -0
  98. package/src/tasks/placeholder/data.ts +21 -0
  99. package/src/tasks/placeholder/spec/input.json +35 -0
  100. package/src/tasks/placeholder/spec/output.json +17 -0
  101. package/src/tasks/question-answering/about.md +56 -0
  102. package/src/tasks/question-answering/data.ts +75 -0
  103. package/src/tasks/question-answering/inference.ts +99 -0
  104. package/src/tasks/question-answering/spec/input.json +67 -0
  105. package/src/tasks/question-answering/spec/output.json +29 -0
  106. package/src/tasks/reinforcement-learning/about.md +167 -0
  107. package/src/tasks/reinforcement-learning/data.ts +75 -0
  108. package/src/tasks/sentence-similarity/about.md +97 -0
  109. package/src/tasks/sentence-similarity/data.ts +101 -0
  110. package/src/tasks/sentence-similarity/inference.ts +32 -0
  111. package/src/tasks/sentence-similarity/spec/input.json +40 -0
  112. package/src/tasks/sentence-similarity/spec/output.json +12 -0
  113. package/src/tasks/summarization/about.md +58 -0
  114. package/src/tasks/summarization/data.ts +76 -0
  115. package/src/tasks/summarization/inference.ts +57 -0
  116. package/src/tasks/summarization/spec/input.json +42 -0
  117. package/src/tasks/summarization/spec/output.json +14 -0
  118. package/src/tasks/table-question-answering/about.md +43 -0
  119. package/src/tasks/table-question-answering/data.ts +59 -0
  120. package/src/tasks/table-question-answering/inference.ts +61 -0
  121. package/src/tasks/table-question-answering/spec/input.json +44 -0
  122. package/src/tasks/table-question-answering/spec/output.json +40 -0
  123. package/src/tasks/tabular-classification/about.md +65 -0
  124. package/src/tasks/tabular-classification/data.ts +68 -0
  125. package/src/tasks/tabular-regression/about.md +87 -0
  126. package/src/tasks/tabular-regression/data.ts +57 -0
  127. package/src/tasks/text-classification/about.md +173 -0
  128. package/src/tasks/text-classification/data.ts +103 -0
  129. package/src/tasks/text-classification/inference.ts +51 -0
  130. package/src/tasks/text-classification/spec/input.json +35 -0
  131. package/src/tasks/text-classification/spec/output.json +11 -0
  132. package/src/tasks/text-generation/about.md +154 -0
  133. package/src/tasks/text-generation/data.ts +114 -0
  134. package/src/tasks/text-generation/inference.ts +200 -0
  135. package/src/tasks/text-generation/spec/input.json +219 -0
  136. package/src/tasks/text-generation/spec/output.json +179 -0
  137. package/src/tasks/text-generation/spec/stream_output.json +103 -0
  138. package/src/tasks/text-to-3d/about.md +62 -0
  139. package/src/tasks/text-to-3d/data.ts +56 -0
  140. package/src/tasks/text-to-audio/inference.ts +143 -0
  141. package/src/tasks/text-to-audio/spec/input.json +31 -0
  142. package/src/tasks/text-to-audio/spec/output.json +17 -0
  143. package/src/tasks/text-to-image/about.md +96 -0
  144. package/src/tasks/text-to-image/data.ts +100 -0
  145. package/src/tasks/text-to-image/inference.ts +75 -0
  146. package/src/tasks/text-to-image/spec/input.json +63 -0
  147. package/src/tasks/text-to-image/spec/output.json +13 -0
  148. package/src/tasks/text-to-speech/about.md +63 -0
  149. package/src/tasks/text-to-speech/data.ts +79 -0
  150. package/src/tasks/text-to-speech/inference.ts +145 -0
  151. package/src/tasks/text-to-speech/spec/input.json +31 -0
  152. package/src/tasks/text-to-speech/spec/output.json +7 -0
  153. package/src/tasks/text-to-video/about.md +41 -0
  154. package/src/tasks/text-to-video/data.ts +102 -0
  155. package/src/tasks/text2text-generation/inference.ts +55 -0
  156. package/src/tasks/text2text-generation/spec/input.json +55 -0
  157. package/src/tasks/text2text-generation/spec/output.json +14 -0
  158. package/src/tasks/token-classification/about.md +76 -0
  159. package/src/tasks/token-classification/data.ts +92 -0
  160. package/src/tasks/token-classification/inference.ts +85 -0
  161. package/src/tasks/token-classification/spec/input.json +65 -0
  162. package/src/tasks/token-classification/spec/output.json +37 -0
  163. package/src/tasks/translation/about.md +65 -0
  164. package/src/tasks/translation/data.ts +70 -0
  165. package/src/tasks/translation/inference.ts +67 -0
  166. package/src/tasks/translation/spec/input.json +50 -0
  167. package/src/tasks/translation/spec/output.json +14 -0
  168. package/src/tasks/unconditional-image-generation/about.md +50 -0
  169. package/src/tasks/unconditional-image-generation/data.ts +72 -0
  170. package/src/tasks/video-classification/about.md +37 -0
  171. package/src/tasks/video-classification/data.ts +84 -0
  172. package/src/tasks/video-classification/inference.ts +59 -0
  173. package/src/tasks/video-classification/spec/input.json +42 -0
  174. package/src/tasks/video-classification/spec/output.json +10 -0
  175. package/src/tasks/video-text-to-text/about.md +98 -0
  176. package/src/tasks/video-text-to-text/data.ts +66 -0
  177. package/src/tasks/visual-question-answering/about.md +48 -0
  178. package/src/tasks/visual-question-answering/data.ts +97 -0
  179. package/src/tasks/visual-question-answering/inference.ts +62 -0
  180. package/src/tasks/visual-question-answering/spec/input.json +41 -0
  181. package/src/tasks/visual-question-answering/spec/output.json +21 -0
  182. package/src/tasks/zero-shot-classification/about.md +40 -0
  183. package/src/tasks/zero-shot-classification/data.ts +70 -0
  184. package/src/tasks/zero-shot-classification/inference.ts +67 -0
  185. package/src/tasks/zero-shot-classification/spec/input.json +50 -0
  186. package/src/tasks/zero-shot-classification/spec/output.json +11 -0
  187. package/src/tasks/zero-shot-image-classification/about.md +75 -0
  188. package/src/tasks/zero-shot-image-classification/data.ts +84 -0
  189. package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
  190. package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
  191. package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
  192. package/src/tasks/zero-shot-object-detection/about.md +45 -0
  193. package/src/tasks/zero-shot-object-detection/data.ts +67 -0
  194. package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
  195. package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
  196. package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
  197. package/src/tokenizer-data.ts +32 -0
  198. package/src/widget-example.ts +125 -0
@@ -0,0 +1,62 @@
1
+ ## Use Cases
2
+
3
+ Text-to-3D models can be used in a wide variety of applications that require 3D, such as games, animation, design, architecture, engineering, marketing, and more.
4
+
5
+ ![Text-to-3D Thumbnail](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/text-to-3d/text-to-3d-thumbnail.png)
6
+
7
+ This task is similar to the [image-to-3d](https://huggingface.co/tasks/image-to-3d) task, but takes text input instead of image input. In practice, this is often equivalent to a combination of [text-to-image](https://huggingface.co/tasks/text-to-image) and [image-to-3d](https://huggingface.co/tasks/image-to-3d). That is, the text is first converted to an image, then the image is converted to 3D.
8
+
9
+ ### Generating Meshes
10
+
11
+ Meshes are the standard representation of 3D in industry.
12
+
13
+ ### Generating Gaussian Splats
14
+
15
+ [Gaussian Splatting](https://huggingface.co/blog/gaussian-splatting) is a rendering technique that represents scenes as fuzzy points.
16
+
17
+ ### Inference
18
+
19
+ Inference for this task typically leverages the [Diffusers](https://huggingface.co/docs/diffusers/index) library for inference, using [Custom Pipelines](https://huggingface.co/docs/diffusers/v0.6.0/en/using-diffusers/custom_pipelines).
20
+
21
+ These are unstandardized and depend on the model. More details can be found in each model repository.
22
+
23
+ ```python
24
+ import torch
25
+ import requests
26
+ import numpy as np
27
+ from io import BytesIO
28
+ from diffusers import DiffusionPipeline
29
+ from PIL import Image
30
+
31
+ pipeline = DiffusionPipeline.from_pretrained(
32
+ "dylanebert/LGM-full",
33
+ custom_pipeline="dylanebert/LGM-full",
34
+ torch_dtype=torch.float16,
35
+ trust_remote_code=True,
36
+ ).to("cuda")
37
+
38
+ input_prompt = "a cat statue"
39
+ result = pipeline(input_prompt, None)
40
+ result_path = "/tmp/output.ply"
41
+ pipeline.save_ply(result, result_path)
42
+ ```
43
+
44
+ In the code above, we:
45
+
46
+ 1. Import the necessary libraries
47
+ 2. Load the `LGM-full` model and custom pipeline
48
+ 3. Define the input prompt
49
+ 4. Run the pipeline on the input prompt
50
+ 5. Save the output to a file
51
+
52
+ ### Output Formats
53
+
54
+ Meshes can be in `.obj`, `.glb`, `.stl`, or `.gltf` format. Other formats are allowed, but won't be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component.
55
+
56
+ Splats can be in `.ply` or `.splat` format. They can be rendered in the gradio [Model3D](https://www.gradio.app/docs/gradio/model3d) component using the [gsplat.js](https://github.com/huggingface/gsplat.js) library.
57
+
58
+ ## Useful Resources
59
+
60
+ - [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course)
61
+ - [3D Arena Leaderboard](https://huggingface.co/spaces/dylanebert/3d-arena)
62
+ - [gsplat.js](https://github.com/huggingface/gsplat.js)
@@ -0,0 +1,56 @@
1
+ import type { TaskDataCustom } from "../index.js";
2
+
3
+ const taskData: TaskDataCustom = {
4
+ datasets: [
5
+ {
6
+ description: "A large dataset of over 10 million 3D objects.",
7
+ id: "allenai/objaverse-xl",
8
+ },
9
+ {
10
+ description: "Descriptive captions for 3D objects in Objaverse.",
11
+ id: "tiange/Cap3D",
12
+ },
13
+ ],
14
+ demo: {
15
+ inputs: [
16
+ {
17
+ label: "Prompt",
18
+ content: "a cat statue",
19
+ type: "text",
20
+ },
21
+ ],
22
+ outputs: [
23
+ {
24
+ label: "Result",
25
+ content: "text-to-3d-3d-output-filename.glb",
26
+ type: "text",
27
+ },
28
+ ],
29
+ },
30
+ metrics: [],
31
+ models: [
32
+ {
33
+ description: "Text-to-3D mesh model by OpenAI",
34
+ id: "openai/shap-e",
35
+ },
36
+ {
37
+ description: "Generative 3D gaussian splatting model.",
38
+ id: "ashawkey/LGM",
39
+ },
40
+ ],
41
+ spaces: [
42
+ {
43
+ description: "Text-to-3D demo with mesh outputs.",
44
+ id: "hysts/Shap-E",
45
+ },
46
+ {
47
+ description: "Text/image-to-3D demo with splat outputs.",
48
+ id: "ashawkey/LGM",
49
+ },
50
+ ],
51
+ summary: "Text-to-3D models take in text input and produce 3D output.",
52
+ widgetModels: [],
53
+ youtubeId: "",
54
+ };
55
+
56
+ export default taskData;
@@ -0,0 +1,143 @@
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 Text To Audio inference
9
+ */
10
+ export interface TextToAudioInput {
11
+ /**
12
+ * The input text data
13
+ */
14
+ inputs: string;
15
+ /**
16
+ * Additional inference parameters
17
+ */
18
+ parameters?: TextToAudioParameters;
19
+ [property: string]: unknown;
20
+ }
21
+
22
+ /**
23
+ * Additional inference parameters
24
+ *
25
+ * Additional inference parameters for Text To Audio
26
+ */
27
+ export interface TextToAudioParameters {
28
+ /**
29
+ * Parametrization of the text generation process
30
+ */
31
+ generation_parameters?: GenerationParameters;
32
+ [property: string]: unknown;
33
+ }
34
+
35
+ /**
36
+ * Parametrization of the text generation process
37
+ *
38
+ * Ad-hoc parametrization of the text generation process
39
+ */
40
+ export interface GenerationParameters {
41
+ /**
42
+ * Whether to use sampling instead of greedy decoding when generating new tokens.
43
+ */
44
+ do_sample?: boolean;
45
+ /**
46
+ * Controls the stopping condition for beam-based methods.
47
+ */
48
+ early_stopping?: EarlyStoppingUnion;
49
+ /**
50
+ * If set to float strictly between 0 and 1, only tokens with a conditional probability
51
+ * greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
52
+ * 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
53
+ * Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
54
+ */
55
+ epsilon_cutoff?: number;
56
+ /**
57
+ * Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to
58
+ * float strictly between 0 and 1, a token is only considered if it is greater than either
59
+ * eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter
60
+ * term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In
61
+ * the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
62
+ * See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
63
+ * for more details.
64
+ */
65
+ eta_cutoff?: number;
66
+ /**
67
+ * The maximum length (in tokens) of the generated text, including the input.
68
+ */
69
+ max_length?: number;
70
+ /**
71
+ * The maximum number of tokens to generate. Takes precedence over max_length.
72
+ */
73
+ max_new_tokens?: number;
74
+ /**
75
+ * The minimum length (in tokens) of the generated text, including the input.
76
+ */
77
+ min_length?: number;
78
+ /**
79
+ * The minimum number of tokens to generate. Takes precedence over min_length.
80
+ */
81
+ min_new_tokens?: number;
82
+ /**
83
+ * Number of groups to divide num_beams into in order to ensure diversity among different
84
+ * groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
85
+ */
86
+ num_beam_groups?: number;
87
+ /**
88
+ * Number of beams to use for beam search.
89
+ */
90
+ num_beams?: number;
91
+ /**
92
+ * The value balances the model confidence and the degeneration penalty in contrastive
93
+ * search decoding.
94
+ */
95
+ penalty_alpha?: number;
96
+ /**
97
+ * The value used to modulate the next token probabilities.
98
+ */
99
+ temperature?: number;
100
+ /**
101
+ * The number of highest probability vocabulary tokens to keep for top-k-filtering.
102
+ */
103
+ top_k?: number;
104
+ /**
105
+ * If set to float < 1, only the smallest set of most probable tokens with probabilities
106
+ * that add up to top_p or higher are kept for generation.
107
+ */
108
+ top_p?: number;
109
+ /**
110
+ * Local typicality measures how similar the conditional probability of predicting a target
111
+ * token next is to the expected conditional probability of predicting a random token next,
112
+ * given the partial text already generated. If set to float < 1, the smallest set of the
113
+ * most locally typical tokens with probabilities that add up to typical_p or higher are
114
+ * kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details.
115
+ */
116
+ typical_p?: number;
117
+ /**
118
+ * Whether the model should use the past last key/values attentions to speed up decoding
119
+ */
120
+ use_cache?: boolean;
121
+ [property: string]: unknown;
122
+ }
123
+
124
+ /**
125
+ * Controls the stopping condition for beam-based methods.
126
+ */
127
+ export type EarlyStoppingUnion = boolean | "never";
128
+
129
+ /**
130
+ * Outputs of inference for the Text To Audio task
131
+ */
132
+ export interface TextToAudioOutput {
133
+ /**
134
+ * The generated audio waveform.
135
+ */
136
+ audio: unknown;
137
+ samplingRate: unknown;
138
+ /**
139
+ * The sampling rate of the generated audio waveform.
140
+ */
141
+ sampling_rate?: number;
142
+ [property: string]: unknown;
143
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$id": "/inference/schemas/text-to-audio/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Text To Audio inference",
5
+ "title": "TextToAudioInput",
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The input text data",
10
+ "type": "string"
11
+ },
12
+ "parameters": {
13
+ "description": "Additional inference parameters",
14
+ "$ref": "#/$defs/TextToAudioParameters"
15
+ }
16
+ },
17
+ "$defs": {
18
+ "TextToAudioParameters": {
19
+ "title": "TextToAudioParameters",
20
+ "description": "Additional inference parameters for Text To Audio",
21
+ "type": "object",
22
+ "properties": {
23
+ "generation_parameters": {
24
+ "description": "Parametrization of the text generation process",
25
+ "$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters"
26
+ }
27
+ }
28
+ }
29
+ },
30
+ "required": ["inputs"]
31
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$id": "/inference/schemas/text-to-audio/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs of inference for the Text To Audio task",
5
+ "title": "TextToAudioOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "audio": {
9
+ "description": "The generated audio waveform."
10
+ },
11
+ "sampling_rate": {
12
+ "type": "number",
13
+ "description": "The sampling rate of the generated audio waveform."
14
+ }
15
+ },
16
+ "required": ["audio", "samplingRate"]
17
+ }
@@ -0,0 +1,96 @@
1
+ ## Use Cases
2
+
3
+ ### Data Generation
4
+
5
+ Businesses can generate data for their use cases by inputting text and getting image outputs.
6
+
7
+ ### Immersive Conversational Chatbots
8
+
9
+ Chatbots can be made more immersive if they provide contextual images based on the input provided by the user.
10
+
11
+ ### Creative Ideas for Fashion Industry
12
+
13
+ Different patterns can be generated to obtain unique pieces of fashion. Text-to-image models make creations easier for designers to conceptualize their design before actually implementing it.
14
+
15
+ ### Architecture Industry
16
+
17
+ Architects can utilise the models to construct an environment based out on the requirements of the floor plan. This can also include the furniture that has to be placed in that environment.
18
+
19
+ ## Task Variants
20
+
21
+ ### Image Editing
22
+
23
+ Image editing with text-to-image models involves modifying an image following edit instructions provided in a text prompt.
24
+
25
+ - **Synthetic image editing**: Adjusting images that were initially created using an input prompt while preserving the overall meaning or context of the original image.
26
+
27
+ ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/edit_p2p.png)
28
+ _Figure taken from ["InstructPix2Pix: Learning to Follow Image Editing Instructions"](https://www.timothybrooks.com/instruct-pix2pix)_
29
+
30
+ - **Real image editing**: Similar to synthetic image editing, except we're using real photos/images. This task is usually more complex.
31
+
32
+ ![Examples](https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/pix2pix.jpeg)
33
+ _Figure taken from ["Prompt-to-Prompt Image Editing with Cross-Attention Control"](https://prompt-to-prompt.github.io)_
34
+
35
+ ### Personalization
36
+
37
+ Personalization refers to techniques used to customize text-to-image models. We introduce new subjects or concepts to the model, which the model can then generate when we refer to them with a text prompt.
38
+
39
+ For example, you can use these techniques to generate images of your dog in imaginary settings, after you have taught the model using a few reference images of the subject (or just one in some cases). Teaching the model a new concept can be achieved through fine-tuning, or by using training-free techniques.
40
+
41
+ ## Inference
42
+
43
+ You can use diffusers pipelines to infer with `text-to-image` models.
44
+
45
+ ```python
46
+ from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
47
+
48
+ model_id = "stabilityai/stable-diffusion-2"
49
+ scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
50
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16)
51
+ pipe = pipe.to("cuda")
52
+
53
+ prompt = "a photo of an astronaut riding a horse on mars"
54
+ image = pipe(prompt).images[0]
55
+ ```
56
+
57
+ You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text-to-image models on Hugging Face Hub.
58
+
59
+ ```javascript
60
+ import { HfInference } from "@huggingface/inference";
61
+
62
+ const inference = new HfInference(HF_TOKEN);
63
+ await inference.textToImage({
64
+ model: "stabilityai/stable-diffusion-2",
65
+ inputs: "award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]",
66
+ parameters: {
67
+ negative_prompt: "blurry",
68
+ },
69
+ });
70
+ ```
71
+
72
+ ## Useful Resources
73
+
74
+ ### Model Inference
75
+
76
+ - [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class)
77
+ - [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index)
78
+ - [Text-to-Image Generation](https://huggingface.co/docs/diffusers/using-diffusers/conditional_image_generation)
79
+ - [Using Stable Diffusion with Core ML on Apple Silicon](https://huggingface.co/blog/diffusers-coreml)
80
+ - [A guide on Vector Quantized Diffusion](https://huggingface.co/blog/vq-diffusion)
81
+ - [🧨 Stable Diffusion in JAX/Flax](https://huggingface.co/blog/stable_diffusion_jax)
82
+ - [Running IF with 🧨 diffusers on a Free Tier Google Colab](https://huggingface.co/blog/if)
83
+ - [Introducing Würstchen: Fast Diffusion for Image Generation](https://huggingface.co/blog/wuerstchen)
84
+ - [Efficient Controllable Generation for SDXL with T2I-Adapters](https://huggingface.co/blog/t2i-sdxl-adapters)
85
+ - [Welcome aMUSEd: Efficient Text-to-Image Generation](https://huggingface.co/blog/amused)
86
+ - Image Editing Demos: [LEDITS++](https://huggingface.co/spaces/editing-images/leditsplusplus), [Turbo Edit](https://huggingface.co/spaces/turboedit/turbo_edit), [InstructPix2Pix](https://huggingface.co/spaces/timbrooks/instruct-pix2pix), [CosXL](https://huggingface.co/spaces/multimodalart/cosxl)
87
+ - Training free Personalization Demos: [Face-to-All](https://huggingface.co/spaces/multimodalart/face-to-all), [InstantStyle](https://huggingface.co/spaces/InstantX/InstantStyle), [RB-modulation](https://huggingface.co/spaces/fffiloni/RB-Modulation), [Photomaker v2](https://huggingface.co/spaces/TencentARC/PhotoMaker-V2)
88
+
89
+ ### Model Fine-tuning
90
+
91
+ - [Finetune Stable Diffusion Models with DDPO via TRL](https://huggingface.co/blog/pref-tuning)
92
+ - [LoRA training scripts of the world, unite!](https://huggingface.co/blog/sdxl_lora_advanced_script)
93
+ - [Using LoRA for Efficient Stable Diffusion Fine-Tuning](https://huggingface.co/blog/lora)
94
+ - LoRA fine tuning Spaces: [FLUX.1 finetuning](https://huggingface.co/spaces/autotrain-projects/train-flux-lora-ease), [SDXL finetuning](https://huggingface.co/spaces/multimodalart/lora-ease)
95
+
96
+ This page was made possible thanks to the efforts of [Ishan Dutta](https://huggingface.co/ishandutta), [Enrique Elias Ubaldo](https://huggingface.co/herrius) and [Oğuz Akif](https://huggingface.co/oguzakif).
@@ -0,0 +1,100 @@
1
+ import type { TaskDataCustom } from "../index.js";
2
+
3
+ const taskData: TaskDataCustom = {
4
+ datasets: [
5
+ {
6
+ description: "RedCaps is a large-scale dataset of 12M image-text pairs collected from Reddit.",
7
+ id: "red_caps",
8
+ },
9
+ {
10
+ description: "Conceptual Captions is a dataset consisting of ~3.3M images annotated with captions.",
11
+ id: "conceptual_captions",
12
+ },
13
+ ],
14
+ demo: {
15
+ inputs: [
16
+ {
17
+ label: "Input",
18
+ content: "A city above clouds, pastel colors, Victorian style",
19
+ type: "text",
20
+ },
21
+ ],
22
+ outputs: [
23
+ {
24
+ filename: "image.jpeg",
25
+ type: "img",
26
+ },
27
+ ],
28
+ },
29
+ metrics: [
30
+ {
31
+ description:
32
+ "The Inception Score (IS) measure assesses diversity and meaningfulness. It uses a generated image sample to predict its label. A higher score signifies more diverse and meaningful images.",
33
+ id: "IS",
34
+ },
35
+ {
36
+ description:
37
+ "The Fréchet Inception Distance (FID) calculates the distance between distributions between synthetic and real samples. A lower FID score indicates better similarity between the distributions of real and generated images.",
38
+ id: "FID",
39
+ },
40
+ {
41
+ description:
42
+ "R-precision assesses how the generated image aligns with the provided text description. It uses the generated images as queries to retrieve relevant text descriptions. The top 'r' relevant descriptions are selected and used to calculate R-precision as r/R, where 'R' is the number of ground truth descriptions associated with the generated images. A higher R-precision value indicates a better model.",
43
+ id: "R-Precision",
44
+ },
45
+ ],
46
+ models: [
47
+ {
48
+ description: "One of the most powerful image generation models that can generate realistic outputs.",
49
+ id: "black-forest-labs/FLUX.1-dev",
50
+ },
51
+ {
52
+ description: "A powerful yet fast image generation model.",
53
+ id: "latent-consistency/lcm-lora-sdxl",
54
+ },
55
+ {
56
+ description: "Text-to-image model for photorealistic generation.",
57
+ id: "Kwai-Kolors/Kolors",
58
+ },
59
+ {
60
+ description: "A powerful text-to-image model.",
61
+ id: "stabilityai/stable-diffusion-3-medium-diffusers",
62
+ },
63
+ ],
64
+ spaces: [
65
+ {
66
+ description: "A powerful text-to-image application.",
67
+ id: "stabilityai/stable-diffusion-3-medium",
68
+ },
69
+ {
70
+ description: "A text-to-image application to generate comics.",
71
+ id: "jbilcke-hf/ai-comic-factory",
72
+ },
73
+ {
74
+ description: "An application to match multiple custom image generation models.",
75
+ id: "multimodalart/flux-lora-lab",
76
+ },
77
+ {
78
+ description: "A powerful yet very fast image generation application.",
79
+ id: "latent-consistency/lcm-lora-for-sdxl",
80
+ },
81
+ {
82
+ description: "A gallery to explore various text-to-image models.",
83
+ id: "multimodalart/LoraTheExplorer",
84
+ },
85
+ {
86
+ description: "An application for `text-to-image`, `image-to-image` and image inpainting.",
87
+ id: "ArtGAN/Stable-Diffusion-ControlNet-WebUI",
88
+ },
89
+ {
90
+ description: "An application to generate realistic images given photos of a person and a prompt.",
91
+ id: "InstantX/InstantID",
92
+ },
93
+ ],
94
+ summary:
95
+ "Text-to-image is the task of generating images from input text. These pipelines can also be used to modify and edit images based on text prompts.",
96
+ widgetModels: ["black-forest-labs/FLUX.1-dev"],
97
+ youtubeId: "",
98
+ };
99
+
100
+ export default taskData;
@@ -0,0 +1,75 @@
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 Text To Image inference
9
+ */
10
+ export interface TextToImageInput {
11
+ /**
12
+ * The input text data (sometimes called "prompt")
13
+ */
14
+ inputs: string;
15
+ /**
16
+ * Additional inference parameters
17
+ */
18
+ parameters?: TextToImageParameters;
19
+ [property: string]: unknown;
20
+ }
21
+
22
+ /**
23
+ * Additional inference parameters
24
+ *
25
+ * Additional inference parameters for Text To Image
26
+ */
27
+ export interface TextToImageParameters {
28
+ /**
29
+ * A higher guidance scale value encourages the model to generate images closely linked to
30
+ * the text prompt, but values too high may cause saturation and other artifacts.
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
+ * The number of denoising steps. More denoising steps usually lead to a higher quality
39
+ * image at the expense of slower inference.
40
+ */
41
+ num_inference_steps?: number;
42
+ /**
43
+ * Override the scheduler with a compatible one.
44
+ */
45
+ scheduler?: string;
46
+ /**
47
+ * Seed for the random number generator.
48
+ */
49
+ seed?: number;
50
+ /**
51
+ * The size in pixel of the output image
52
+ */
53
+ target_size?: TargetSize;
54
+ [property: string]: unknown;
55
+ }
56
+
57
+ /**
58
+ * The size in pixel of the output image
59
+ */
60
+ export interface TargetSize {
61
+ height: number;
62
+ width: number;
63
+ [property: string]: unknown;
64
+ }
65
+
66
+ /**
67
+ * Outputs of inference for the Text To Image task
68
+ */
69
+ export interface TextToImageOutput {
70
+ /**
71
+ * The generated image returned as raw bytes in the payload.
72
+ */
73
+ image: unknown;
74
+ [property: string]: unknown;
75
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "$id": "/inference/schemas/text-to-image/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Text To Image inference",
5
+ "title": "TextToImageInput",
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The input text data (sometimes called \"prompt\")",
10
+ "type": "string"
11
+ },
12
+ "parameters": {
13
+ "description": "Additional inference parameters",
14
+ "$ref": "#/$defs/TextToImageParameters"
15
+ }
16
+ },
17
+ "$defs": {
18
+ "TextToImageParameters": {
19
+ "title": "TextToImageParameters",
20
+ "description": "Additional inference parameters for Text To Image",
21
+ "type": "object",
22
+ "properties": {
23
+ "guidance_scale": {
24
+ "type": "number",
25
+ "description": "A higher guidance scale value encourages the model to generate images closely linked to the text prompt, but values too high may cause saturation and other artifacts."
26
+ },
27
+ "negative_prompt": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string"
31
+ },
32
+ "description": "One or several prompt to guide what NOT to include in image generation."
33
+ },
34
+ "num_inference_steps": {
35
+ "type": "integer",
36
+ "description": "The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
37
+ },
38
+ "target_size": {
39
+ "type": "object",
40
+ "description": "The size in pixel of the output image",
41
+ "properties": {
42
+ "width": {
43
+ "type": "integer"
44
+ },
45
+ "height": {
46
+ "type": "integer"
47
+ }
48
+ },
49
+ "required": ["width", "height"]
50
+ },
51
+ "scheduler": {
52
+ "type": "string",
53
+ "description": "Override the scheduler with a compatible one."
54
+ },
55
+ "seed": {
56
+ "type": "integer",
57
+ "description": "Seed for the random number generator."
58
+ }
59
+ }
60
+ }
61
+ },
62
+ "required": ["inputs"]
63
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$id": "/inference/schemas/text-to-image/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs of inference for the Text To Image task",
5
+ "title": "TextToImageOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "image": {
9
+ "description": "The generated image returned as raw bytes in the payload."
10
+ }
11
+ },
12
+ "required": ["image"]
13
+ }