Cannot upload zipped model and weights for LudwigAI app

Hi guys,

I’m building a machine learning app via LudwigAI and I would like users to be able to upload model weights and all related files - 5 files in total, see screenshot below:

For that, I’ve tried to use this little hack that I’ve previously used to upload Kera’s weights, taken from here:

stream = st.file_uploader("Ludwig models (.zip)", type="zip")
    if stream is not None:
        myzipfile = zipfile.ZipFile(stream)
        with tempfile.TemporaryDirectory() as tmp_dir:
            root_folder = myzipfile.namelist()[0]  # e.g. "model.h5py"
            model_dir = os.path.join(tmp_dir, root_folder)
            modelLoaded = LudwigModel.load(model_dir)


I’ve currently the following error:

I’ll try other variations, yet if anyone has a fix that’ll be appreciated! :slight_smile:

Many thanks,

Are you sure that ZipFile takes a buffer, not just an actual file?

1 Like


As per our Slack discussion, I’ll try this:

I’ll report back here on the outcomes.

Thanks again Randy!