2

I have converted a model to a BytesIO object using joblib in the following way:

from io import BytesIO
import joblib

bytes_container = BytesIO()
joblib.dump(model, bytes_container)
bytes_container.seek(0)  # update to enable reading

bytes_model = bytes_container.read()

How do I convert the bytes_model back to a model now. joblib.load asks for a filename instead of a bytestring.

1 Answers1

2

I think you can just do the following:

bytes_container = BytesIO()
joblib.dump(model, bytes_container)

bytes_container.seek(0)
model = joblib.load(bytes_container)
James Roseman
  • 1,614
  • 4
  • 18
  • 24