OSError: Unable to open file (file signature not found)

@Thisara_Shyamalee This looks like a bug in how Streamlit Cloud clones Git LFS objects. I’ve raised this issue internally.

In the meantime, here’s a workaround:

  1. Right after your imports, include the following snippet to download your .h5 model with curl to Streamlit Cloud:
import subprocess
if not os.path.isfile('model.h5'):
    subprocess.run(['curl --output model.h5 "https://media.githubusercontent.com/media/ShyamaleeT/glaucocare/main/sep_5.h5"'], shell=True)
  1. Replace model = tf.keras.models.load_model('sep_5.h5', compile=False) with:
model = tf.keras.models.load_model('model.h5', compile=False)
  1. Don’t delete or rename the sep_5.h5 file from your repo, as we’re using its url to download your model in Step 1

Once you make the above changes, your app should successfully load your model! :rocket:

2 Likes