Last active
September 2, 2020 13:39
-
-
Save poltys/ea5314716810d132f6e8efba1eb40c0e to your computer and use it in GitHub Desktop.
streamlit-dashboard-upload-h5-model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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