Skip to content

Instantly share code, notes, and snippets.

@poltys
Last active September 2, 2020 13:39
Show Gist options
  • Save poltys/ea5314716810d132f6e8efba1eb40c0e to your computer and use it in GitHub Desktop.
Save poltys/ea5314716810d132f6e8efba1eb40c0e to your computer and use it in GitHub Desktop.
streamlit-dashboard-upload-h5-model
import zipfile
import tempfile
stream = st.file_uploader('TF.Keras model file (.h5py.zip)', type='zip')
if stream is not None:
myzipfile = zipfile.ZipFile(stream)
with tempfile.TemporaryDirectory() as tmp_dir:
myzipfile.extractall(tmp_dir)
root_folder = myzipfile.namelist()[0] # e.g. "model.h5py"
model_dir = os.path.join(tmp_dir, root_folder)
#st.info(f'trying to load model from tmp dir {model_dir}...')
model = tf.keras.models.load_model(model_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment