Storing Machine Learning Model in Anvil

Okay, I’m back to a computer. Give this a try to see if you can read in your model.

import anvil.media

# in a server function
with anvil.media.TempFile(your_media_object) as file_name:
  # Now there is a file in the filesystem with the contents of media object
  # The file_name variable is a string of its full path.

  my_model = joblib.load(file_name)

Here are the docs I was referring to that detail dealing with media objects and the filesystem.

2 Likes