Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Serialization & Deserialization for Requests","local":"serialization--deserialization-for-requests","sections":[],"depth":1}"> | |
| <link href="/docs/inference-endpoints/pr_113/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/entry/start.d1c14968.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/chunks/scheduler.389d799c.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/chunks/singletons.16c9b508.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/chunks/paths.58d119e0.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/entry/app.18050d92.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/chunks/index.8f81d18f.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/nodes/0.ce016c16.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/nodes/23.c2458a50.js"> | |
| <link rel="modulepreload" href="/docs/inference-endpoints/pr_113/en/_app/immutable/chunks/getInferenceSnippets.8efa8e08.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Serialization & Deserialization for Requests","local":"serialization--deserialization-for-requests","sections":[],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="serialization--deserialization-for-requests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#serialization--deserialization-for-requests"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Serialization & Deserialization for Requests</span></h1> <p data-svelte-h="svelte-1213y42">Hugging Face Inference Endpount comes with a default serving container which is used for all <a href="/docs/inference-endpoints/supported_tasks">supported Transformers and Sentence-Transformers tasks</a> and for <a href="/docs/inference-endpoints/guides/custom_handler">custom inference handler</a>. | |
| The serving container takes care of serialization and deserialization of the request and response payloads based on the <code>content-type</code> and <code>accept</code> headers of the request. | |
| That means that when you send a request with a JSON body and a <code>content-type: application/json</code> header, the serving container will deserialize the JSON payload into a Python dictionary and pass it to the inference handler and if you send | |
| a request with a <code>accept: image/png</code> header, the serving container will serialize the response from the task/custom handler into a image.</p> <p data-svelte-h="svelte-46ywuy">Below is a list of supported <code>content-types</code> and the deserialized payload that is passed to the inference handler.</p> <table data-svelte-h="svelte-1agffaq"><thead><tr><th>Content-Type</th> <th>Payload</th></tr></thead> <tbody><tr><td>application/json</td> <td><code>dict</code></td></tr> <tr><td>text/csv</td> <td><code>raw</code></td></tr> <tr><td>text/plain</td> <td><code>raw</code></td></tr> <tr><td>image/png</td> <td><code>binary</code></td></tr> <tr><td>image/jpeg</td> <td><code>binary</code></td></tr> <tr><td>image/jpg</td> <td><code>binary</code></td></tr> <tr><td>image/tiff</td> <td><code>binary</code></td></tr> <tr><td>image/bmp</td> <td><code>binary</code></td></tr> <tr><td>image/gif</td> <td><code>binary</code></td></tr> <tr><td>image/webp</td> <td><code>binary</code></td></tr> <tr><td>image/x-image</td> <td><code>binary</code></td></tr> <tr><td>audio/x-flac</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/flac</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/mpeg</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/x-mpeg-3</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/wave</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/wav</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/x-wav</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/ogg</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/x-audio</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/webm</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/webm;codecs=opus</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/AMR</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/amr</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/AMR-WB</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/AMR-WB+</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/m4a</td> <td><code>{"inputs": bytes(body)}</code></td></tr> <tr><td>audio/x-m4a</td> <td><code>{"inputs": bytes(body)}</code></td></tr></tbody></table> <p data-svelte-h="svelte-1m5j6ln">Below is a list of supported <code>accept</code> headers and the serialized payload is returned.</p> <table data-svelte-h="svelte-79p974"><thead><tr><th>Accept</th> <th>Payload</th></tr></thead> <tbody><tr><td>application/json</td> <td><code>JSON</code></td></tr> <tr><td>text/csv</td> <td><code>raw</code></td></tr> <tr><td>text/plain</td> <td><code>raw</code></td></tr> <tr><td>image/png</td> <td><code>binary</code></td></tr> <tr><td>image/jpeg</td> <td><code>binary</code></td></tr> <tr><td>image/jpg</td> <td><code>binary</code></td></tr> <tr><td>image/tiff</td> <td><code>binary</code></td></tr> <tr><td>image/bmp</td> <td><code>binary</code></td></tr> <tr><td>image/gif</td> <td><code>binary</code></td></tr> <tr><td>image/webp</td> <td><code>binary</code></td></tr> <tr><td>image/x-image</td> <td><code>binary</code></td></tr></tbody></table> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/hf-endpoints-documentation/blob/main/docs/source/others/serialization.mdx" target="_blank"><span data-svelte-h="svelte-1kd6by1"><</span> <span data-svelte-h="svelte-x0xyl0">></span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_87vzq7 = { | |
| assets: "/docs/inference-endpoints/pr_113/en", | |
| base: "/docs/inference-endpoints/pr_113/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/inference-endpoints/pr_113/en/_app/immutable/entry/start.d1c14968.js"), | |
| import("/docs/inference-endpoints/pr_113/en/_app/immutable/entry/app.18050d92.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 23], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 8.12 kB
- Xet hash:
- c82dab96168cf880c04e08baf304ce162dec87140363d4ebb27da1c34efbb14b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.