it looks like ‘saved’ in saved = m.save(‘my_model.h5’, save_format=‘h5’) is still going to be the result of m.save, which as stucork pointed out might be ‘None’
You seem very close, the .save method probably creates a file called ‘my_model.h5’ in the working directory (because that’s what you chose to put in as a temporary file name)
Try changing the:
media_obj = anvil.media.from_file(saved)
to:
media_obj = anvil.media.from_file(‘my_model.h5’)
I also strongly suggest you put a small delay between saving your file and turning it into a media object, aberrant behavior may be caused by disk cashing causing your ‘my_model.h5’ file to fail to be completely written before being scooped up by the anvil media object library.
something like :
from time import sleep
sleep(0.25)
after you save your model should keep this from happening (it would only fail sometimes, which can be frustrating)
You are probably very close to getting it to work.