how to save the model in jit format(torch.script)
See original GitHub issueHi guys, i am having the trained model it was saved by using torch.save() function. i am trying to save the trained model in torch.jit.save () function i cant able to do. The error which i faced is :
Traceback (most recent call last):
File "train.py", line 504, in <module>
train()
File "train.py", line 385, in train
yolact_net.save_weights(save_path(epoch, iteration))
File "/home/reorder/SAI_SUBRAMANI/Programs/MAIN/YOLACT/yolact-master/yolact.py", line 483, in save_weights
torch.jit.save(self.state_dict(), path)
File "/home/reorder/.local/lib/python3.6/site-packages/torch/jit/__init__.py", line 153, in save
m.save(f, _extra_files=_extra_files)
AttributeError: 'collections.OrderedDict' object has no attribute 'save'
changes i did , batch size = 1 and cuda = True. as they mentioned that Pytorch DataParallel still doesn’t support JIT Script Modules, i used batch size =1 and the training started to use torch.jit.ScriptModule and torch.jit.script_method.After the training completed it through error when it tries to save
suggest some ideas,struggling more than 3 days.If any way to convert the pretrained model to jit format is its there help me.
System configuration:
ubuntu:18.04 python : python3.6.9 pytorch :1.4.0 cuda_version: 10.2 Driver :440.64.00
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
torch.jit.save — PyTorch 1.13 documentation
Save an offline version of this module for use in a separate process. The saved module serializes all of the methods, submodules, parameters,...
Read more >Using TorchScript to serialize and deploy model
TorchScript is a way to create serializable and optimizable models from PyTorch code. It allows users to saved their models from a Python...
Read more >How to convert your PyTorch model to TorchScript | djl
There are two ways to convert your model to TorchScript: tracing and scripting. We will only demonstrate the first one, tracing, but you...
Read more >PyTorch JIT and TorchScript - Towards Data Science
TorchScript saves/loads modules into an archive format. This archive is a standalone representation of the model and can be loaded into an ...
Read more >Saving PyTorch model with no access to model class code
I think the simplest thing is to use trace = torch.jit.trace(model, typical_input) and then torch.jit.save(trace, path) .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @mchmu
hi @mchmu , i founded why this error occurs. This is due to the output tensors returning a dict values. can i know what you are trying to do?. If you have the trained model then you can convert the trained model which was trained in pytorch to torch_script. Its a simple step.