I’m trying to upload trained models saved on github using pickle / joblib, but I’m not able to do it on streamlit cloud
This is certainly possible to use serialized/trained models (pickle/joblib) with Streamlit Community Cloud.
Here’s an app and the corresponding repo deployed on Streamlit Community Cloud that I made. It loads a pre-trained ML model (pickle) from the GitHub repo via the pickle
library.
First, import pickle
import pickle
Next, the model is loaded:
model = pickle.load(open('data/oversampling_PubChem_RandomForestClassifier.pkl', 'rb'))
And finally the model is used to make predictions via:
model.predict(input_X)
Thanks @dataprofessor you’re right, my mistake was in building the serialized file.
This solution works for me:
save the model to disk
with open(‘LR_classifier.pkl’, ‘wb’) as pickle_out:
serialized_classifier = pickle.dumps(LR_classifier)
pickle_out.write(serialized_classifier)
loading in the model to predict on the data
with open(‘./data/LR_classifier.pkl’, ‘rb’) as pickle_in:
LR_classifier = pickle.load(pickle_in)
You’re welcome, Glad to hear that it works now!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.