Files & outputs
Cog models take files in (audio, images, video) and often produce files. Turion’s clients handle both directions.
File inputs
Section titled “File inputs”Remote (turion run, SDK client.run, REST)
Section titled “Remote (turion run, SDK client.run, REST)”File inputs are uploaded to Turion storage before the prediction is created:
-
CLI:
-i key=@pathTerminal window turion run acme/whisper -i audio=@sample.wav -
Python SDK: a
pathlib.Path, an open file object, or a string that names an existing local file, anywhere in the input dict or list:client.run("acme/whisper", input={"audio": "sample.wav"}) # str pathclient.run("acme/whisper", input={"audio": Path("sample.wav")}) # Pathclient.run("acme/whisper", input={"audio": open("sample.wav", "rb")})
Over REST this is two calls: POST /v1/uploads returns a presigned upload_url and an
input_ref (a turion://… reference); PUT the bytes to the URL and pass the input_ref as the
input value. See the REST API reference for the
shapes. Upload URLs expire at expires_at, so upload shortly before you submit.
Local (turion cog predict)
Section titled “Local (turion cog predict)”Nothing is uploaded. @file inputs are inlined into the request as base64 data: URIs and sent
straight to the container on your machine.
File outputs
Section titled “File outputs”A prediction’s output is JSON. Files appear inside it as URLs or data URIs, depending on where
the model ran:
Remote
Section titled “Remote”File outputs are stored by Turion and returned as signed HTTPS URLs inside the output JSON.
The URLs expire 24 hours after the run, so download what you want to keep rather than storing the
links. turion run -o DIR saves every output file as DIR/{prediction_id}/{key}.{ext} when the
run finishes:
turion run acme/sdxl -i prompt="a lighthouse" -o outputs/turion prediction get <prediction-id> # output contains https://… linkscurl -o out.png "https://…"turion cog predict receives file outputs as data: URIs and writes them to your working
directory as output.0.png, output.1.wav, … (extension from the MIME type). The printed JSON
has the file paths in place of the base64:
turion cog predict sdxl-demo:latest -i prompt="a lighthouse"{ "image": "output.0.png"}Size notes
Section titled “Size notes”- Prefer
@fileuploads to base64 inkey=valuestrings: uploads go straight to storage instead of through the prediction request body. - Model weights do not belong in inputs. Bake them into the image or download them in
setup(); see Cog on Turion.