nebuly icon indicating copy to clipboard operation
nebuly copied to clipboard

How to load the final model for a second time run?

Open jues opened this issue 2 years ago • 2 comments

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?

jues avatar Mar 03 '22 04:03 jues

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 😄.

diegofiori avatar Mar 03 '22 09:03 diegofiori

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.

shiyu22 avatar Jul 25 '22 12:07 shiyu22