nebuly
nebuly copied to clipboard
How to load the final model for a second time run?
Hi, the function optimize_torch_model
accepts a save_dir param to save the final model.
optimized_model = optimize_torch_model(
model, batch_size=bs, input_sizes=input_sizes, save_dir=save_dir
)
but how can I load the optimized_model
for a second time run?
Hi jues!!! You raised a good point that is indeed missing in the documentation! You can load the model by running the following commands
from nebullvm.inference_learners.base import LearnerMetadata
path = "path-to-directory-where-the-model-is-saved"
loaded_model = LearnerMetadata.read(path).load_model(path)
For the next release it would be nice to add a load_model
function wrapping the code above. I'll work on that 😄.
Hi jues!!! You raised a good point that is indeed missing in the documentation! You can load the model by running the following commands
from nebullvm.inference_learners.base import LearnerMetadata path = "path-to-directory-where-the-model-is-saved" loaded_model = LearnerMetadata.read(path).load_model(path)
For the next release it would be nice to add a
load_model
function wrapping the code above. I'll work on that 😄.
In the latest version, should run this loaded_model = LearnerMetadata.read(path + '/optimized_model').load_model(path)
, and I think here is a bug.