- Public on Hugging Face (default, example here)
- Private on Hugging Face
- Bundled directly with the Truss
- Public cloud storage like S3
- Private cloud storage like S3
Bundling model weights in Truss
You can bundle model data directly with your model in Truss. To do so, use the Truss’data
folder to store any necessary files.
Here’s an example of the data
folder for a Truss of Stable Diffusion 2.1.
self._data_dir
variable in the load()
function of model/model.py
:
Loading public model weights from S3
Bundling multi-gigabyte files with your Truss can be difficult if you have limited local storage and can make deployment slow. Instead, you can store your model weights and other files in cloud storage like S3. Using files from S3 requires four steps:- Uploading the content of your data directory to S3
- Setting
external_data
in config.yaml - Removing unneeded files from the
data
directory - Accessing data correctly in the model
data/
directory to S3.
First, add the URLs for hosted versions of the large files to config.yaml
:
data
folder. The Stable Diffusion Truss has the following directory structure after large files are removed:
model/model.py
does not need to be changed and will automatically pull the large files from the provided links.
Loading private model weights from S3
If your model weights are proprietary, you’ll be storing them in a private S3 bucket or similar access-restricted data store. Accessing these model files works exactly the same as above, but first uses secrets to securely authenticate your model with the data store. First, set the following secrets inconfig.yaml
. Set the values to null
, only the keys are needed here.
__init__()
function:
boto3
package to access your model weights in load()
.
When you’re ready to deploy your model, make sure to pass is_trusted=True
to baseten.deploy()
: