Skip to content

apokerce/PyTorchJitQmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pytorch torch.jit.trace

Pytorch allow users to trace their nn.module or python functions and create executable or ScriptFunction. This scripts then can be called using pytorch built in methods like jit.load(). In this repo, a python nn model which also has user defined functions is traced and called in C++ using qmake.

Installations

Python Side

  • It depends on the models requirements check the requirements.txt file if provided by the authors

C++ Side

For installation guides of tools in C++ side you can click on the required tool.

Code to Trace the Model in Python

$ traced_model = torch.jit.trace(model_object, example_input)
$ traced_model.save('traced_model.pt')

For More Information on Tracing Model

Usage

$ Do not forget to change the paths defined in pro file
$ Place your traced model in debug folder of your project
$ Change line 17 according to your input model
$ Change line 29 to your video input
$ Run the main.cpp code to observe the output

Faced Problems.

Class with torc.autograd.Function

This method is used to calculate the gradients in the traning phase. Since we are going to use the model in eval mode, we can change it to be regular forwarding function. Hence, if you encounter such a problem, convert function accordingly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published