This message was deleted.
# ask-for-help
s
This message was deleted.
🍱 1
🏁 1
s
Hi, you can use the
custom_objects
field in the save model.
Copy code
bentoml.pytorch.save_model(
    "demo_mnist",   # model name in the local model store
    trained_model,  # model instance being saved
    custom_objects={    # save additional user-defined python objects
        "tokenizer": tokenizer_object,
    }
)
And get the custom object with
model.custom_objects[]
.
Copy code
import bentoml
bento_model: bentoml.Model = bentoml.models.get("iris_clf:latest")
print(bento_model.custom_objects)
Read more here. https://docs.bentoml.org/en/latest/concepts/model.html
а
Thanks! Can
custom_objects
field be used to put the binary fine into the model as is? As far as I understand, I'd have to first read the file content into python as e.g. bytes object and then it will be saved as pickle, so the actual file in the model folder will be different as pickle adds its header I guess.
s
If it is a file you’d like to include, you can add it through the
includes
field in the
bentofile.yaml
. It will get packaged into the bento. You can load the file using Python.
а
Nice trick with
includes
, thank you!