File size: 8,437 Bytes
2c729ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
\# Spaces Configuration Reference



Spaces are configured through the `YAML` block at the top of the \*\*README.md\*\* file at the root of the repository. All the accepted parameters are listed below.



\*\*`title`\*\* : \_string\_  

Display title for the Space.  



\*\*`emoji`\*\* : \_string\_  

Space emoji (emoji-only character allowed).  



\*\*`colorFrom`\*\* : \_string\_  

Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray).  



\*\*`colorTo`\*\* : \_string\_  

Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray).  



\*\*`sdk`\*\* : \_string\_  

Can be either `gradio`, `docker`, or `static`.  



\*\*`python\_version`\*\*: \_string\_  

Any valid Python `3.x` or `3.x.x` version.  

Defaults to `3.10`.  



\*\*`sdk\_version`\*\* : \_string\_  

Specify the version of Gradio to use.

All versions of Gradio are supported.  



\*\*`suggested\_hardware`\*\* : \_string\_  

Specify the suggested \[hardware](https://huggingface.co/docs/hub/spaces-gpus) on which this Space must be run.  

Useful for Spaces that are meant to be duplicated by other users.  

Setting this value will not automatically assign an hardware to this Space.  

Value must be a valid hardware flavor. Current valid hardware flavors:

\- CPU: `"cpu-basic"`, `"cpu-upgrade"`

\- GPU: `"t4-small"`, `"t4-medium"`, `"l4x1"`,

 	`"l4x4"`, `"a10g-small"`, `"a10g-large"`, `"a10g-largex2"`,

 	`"a10g-largex4"`,`"a100-large"`

\- TPU: `"v5e-1x1"`, `"v5e-2x2"`, `"v5e-2x4"`



\*\*`suggested\_storage`\*\* : \_string\_  

Specify the suggested \[permanent storage](https://huggingface.co/docs/hub/spaces-storage) on which this Space must be run.  

Useful for Spaces that are meant to be duplicated by other users.  

Setting this value will not automatically assign a permanent storage to this Space.  

Value must be one of `"small"`, `"medium"` or `"large"`.  



\*\*`app\_file`\*\* : \_string\_  

Path to your main application file (which contains either `gradio` Python code or `static` html code).  

Path is relative to the root of the repository.  



\*\*`app\_build\_command`\*\* : \_string\_  

For static Spaces, command to run first to generate the HTML to render. Example: `npm run build`. 



This is used in conjunction with `app\_file` which points to the built index file: e.g. `app\_file: dist/index.html`. 



Each update, the build command will run in a Job and the build output will be stored in `refs/convert/build`,

which will be served by the Space. See an example at https://huggingface.co/spaces/coyotte508/static-vite



\*\*`app\_port`\*\* : \_int\_  

Port on which your application is running. Used only if `sdk` is `docker`. Default port is `7860`.



\*\*`base\_path`\*\*: \_string\_

For non-static Spaces, initial url to render. Needs to start with `/`. For static Spaces, use `app\_file` instead.



\*\*`fullWidth`\*\*: \_boolean\_  

Whether your Space is rendered inside a full-width (when `true`) or fixed-width column (ie. "container" CSS) inside the iframe.

Defaults to `true`.



\*\*`header`\*\*: \_string\_  

Can be either `mini` or `default`. If `header` is set to `mini` the space will be displayed full-screen with a mini floating header .   



\*\*`short\_description`\*\*: \_string\_

A short description of the Space. This will be displayed in the Space's thumbnail.



\*\*`models`\*\* : \_List\[string]\_  

HF model IDs (like `openai-community/gpt2` or `deepset/roberta-base-squad2`) used in the Space.

Will be parsed automatically from your code if not specified here.  



\*\*`datasets`\*\* : \_List\[string]\_  

HF dataset IDs (like `mozilla-foundation/common\_voice\_13\_0` or `oscar-corpus/OSCAR-2109`) used in the Space.

Will be parsed automatically from your code if not specified here.  



\*\*`tags`\*\* : \_List\[string]\_  

List of terms that describe your Space task or scope.  



\*\*`thumbnail`\*\*: \_string\_  

URL for defining a custom thumbnail for social sharing.



\*\*`pinned`\*\* : \_boolean\_  

Whether the Space stays on top of your profile. Can be useful if you have a lot of Spaces so you and others can quickly see your best Space.  



\*\*`hf\_oauth`\*\* : \_boolean\_  

Whether a connected OAuth app is associated to this Space. See \[Adding a Sign-In with HF button to your Space](https://huggingface.co/docs/hub/spaces-oauth) for more details.



\*\*`hf\_oauth\_scopes`\*\* : \_List\[string]\_

Authorized scopes of the connected OAuth app. `openid` and `profile` are authorized by default and do not need this parameter. See \[Adding a Sign-In with HF button to your space](https://huggingface.co/docs/hub/spaces-oauth) for more details.



\*\*`hf\_oauth\_expiration\_minutes`\*\* : \_int\_

Duration of the OAuth token in minutes. Defaults to 480 minutes (8 hours). Maximum duration is 43200 minutes (30 days). See \[Adding a Sign-In with HF button to your space](https://huggingface.co/docs/hub/spaces-oauth) for more details.



\*\*`hf\_oauth\_authorized\_org`\*\* : \_string\_ or \_List\[string]\_

Restrict OAuth access to members of specific organizations. See \[Adding a Sign-In with HF button to your space](https://huggingface.co/docs/hub/spaces-oauth) for more details.



\*\*`disable\_embedding`\*\* : \_boolean\_  

Whether the Space iframe can be embedded in other websites.

Defaults to false, i.e. Spaces \*can\* be embedded.



\*\*`startup\_duration\_timeout`\*\*: \_string\_  

Set a custom startup duration timeout for your Space. This is the maximum time your Space is allowed to start before it times out and is flagged as unhealthy.

Defaults to 30 minutes, but any valid duration (like `1h`, `30m`) is acceptable.



\*\*`custom\_headers`\*\* : \_Dict\[string, string]\_  

Set custom HTTP headers that will be added to all HTTP responses when serving your Space.  

For now, only the \[cross-origin-embedder-policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy) (COEP), \[cross-origin-opener-policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy) (COOP), and \[cross-origin-resource-policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy) (CORP) headers are allowed. These headers can be used to set up a cross-origin isolated environment and enable powerful features like `SharedArrayBuffer`, for example:



```yaml



custom\_headers:



  cross-origin-embedder-policy: require-corp



  cross-origin-opener-policy: same-origin



  cross-origin-resource-policy: cross-origin



```



\*Note:\* all headers and values must be lowercase.



\*\*`preload\_from\_hub`\*\*: \_List\[string]\_

Specify a list of Hugging Face Hub models or other large files to be preloaded during the build time of your Space. This optimizes the startup time by having the files ready when your application starts. This is particularly useful for Spaces that rely on large models or datasets that would otherwise need to be downloaded at runtime.



The format for each item is `"repository\_name"` to download all files from a repository, or `"repository\_name file1,file2"` for downloading specific files within that repository. You can also specify a specific commit to download using the format `"repository\_name file1,file2 commit\_sha256"`. 



Example usage:

```yaml



preload\_from\_hub:



  - warp-ai/wuerstchen-prior text\_encoder/model.safetensors,prior/diffusion\_pytorch\_model.safetensors



  - coqui/XTTS-v1



  - openai-community/gpt2 config.json 11c5a3d5811f50298f278a704980280950aedb10



```

In this example, the Space will preload specific .safetensors files from `warp-ai/wuerstchen-prior`, the complete `coqui/XTTS-v1` repository, and a specific revision of the `config.json` file in the `openai-community/gpt2` repository from the Hugging Face Hub during build time.



> \[!WARNING]

> Files are saved in the default `huggingface\_hub` disk cache `~/.cache/huggingface/hub`. If you application expects them elsewhere or you changed your `HF\_HOME` variable, this pre-loading does not follow that at this time.