How to create a class from a .pt file model, or load a model from a .pt file without the class

Hello!

I have a .pt file for a ASR model that I didn’t create, and I want to deploy it. But I don’t have it’s parameters, or the class that I should use to deploy it.

Is there a way to create the class from the .pt file?

If not, how could I deploy the model without it’s class? Is there a pytorch framework with which I could deploy this model?

Thank you!

It depends what the .pt files contains and how it was stored.
If the state_dict was stored in it, you would need the actual model code to recreate a model instance and to be able to load the state_dict afterwards. The same would apply with even more restrictions, if the entire model was saved via torch.save(model, PATH), as you would also need to restore the actual source code structure.
However, if a scripted model was stored via torch.jit.save(scipted_model, PATH) you could load it directly via torch.jit.load.