How to download large model files to the sharing app?

Hi @metasemantic,

Model weights can be saved within a GitHub release:

You can then download these within your Streamlit app using:

import urllib.request

url = 'https://github.com/pymedphys/data/releases/download/VacbagModelWeights/unet_vacbag_512_dsc_epoch_120.hdf5'
filename = url.split('/')[-1]

urllib.request.urlretrieve(url, filename)

Within the PyMedPhys repository (https://github.com/pymedphys/pymedphys) I go a few steps further and also cache the download to the user’s home directory and a few other things so that it doesn’t need to be redownloaded. See that logic over at:

Zenodo (https://zenodo.org/) also offers unlimited free large file storage.

2 Likes