How can I prevent TorchScript from including the original Python source code?

I’ve created a model via torch.jit.script(...).save('file.pt') in Python, and want to export it without including the original Python source code at all. This is because the model is going to be deployed on-prem for external clients, and I’d like to make it a bit less trivial for clients to see how the underlying model works. Is there any way to not include the original Python source code in the .pt file? Also, is there any other way to further obfuscate the TorchScript? I know there are Python obfuscation tools, such as pyarmor, but I wonder if they’d interfere with optimizations, and also really put TorchScript’s ability to interpret Python correctly to the test.

1 Like